Hagop Posted October 31, 2015 Share Posted October 31, 2015 HiThis 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 declarecart.parent = camera;the cart vanishes So instead I am usingcart.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 ? Quote Link to comment Share on other sites More sharing options...
gryff Posted October 31, 2015 Share Posted October 31, 2015 Hagop, with :cart.parent = camera;you are effectively standing in the cart 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 Quote Link to comment Share on other sites More sharing options...
Hagop Posted November 2, 2015 Author Share Posted November 2, 2015 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.? Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 2, 2015 Share Posted November 2, 2015 Something like that maybe: http://www.babylonjs-playground.com/#1LT3VZ ? Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 2, 2015 Share Posted November 2, 2015 This is such a nice hack, iiceman :-) You can save like 2 nanoseconds every second doing that - http://www.babylonjs-playground.com/#1LT3VZ#1 iiceman and jerome 2 Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 2, 2015 Share Posted November 2, 2015 I see, because it's a direct reference of the rotation... no need to set it over and over again, cool! Quote Link to comment Share on other sites More sharing options...
Hagop Posted November 2, 2015 Author Share Posted November 2, 2015 thanks iiceman Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.