Jump to content

how to move a mesh with FreeCamera?


Hagop
 Share

Recommended Posts

Hi

This question might sound simple but...

I import a shopping cart into my scene using SceneLoader.ImportMesh. I want to link the cart to my FreeCamera so that when the camera moves, the mesh will follow the camera.

 

If I declare

cart.parent = camera;

the cart vanishes

 

So instead I am using

cart.parent = camera.parent;

which doesn't make sense to me but at least the cart does appear in the scene but does not move. Any ideas ?

 

Link to comment
Share on other sites

Hagop, with :

cart.parent = camera;

you are effectively standing in the cart :o

 

Try adding an offset to the cart  with:

cart.position = new BABYLON.Vector3(x,y,z);

and adjusting the x,y,z values until the cart appears where you want it. My guess - just the y and z values for the cart to be in front of you.

 

You may have to scale the cart too.

 

Then parent to the camera.

 

Hope that helps.

 

cheers, gryff :)

Link to comment
Share on other sites

Thanks gryff for the reply. I can import, position and adjust the cart. However, what I want is the cart to move with the Free Camera. In essence I want  the cart to be a First Person View. Additionally I want the cart to move left and right when I move the Free Camera with left and right arrows, but when I move the camera up or down with up and down arrows, I want the cart to remain still.?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...