zincman320 Posted November 26, 2013 Share Posted November 26, 2013 I have this camera:var camera = new BABYLON.ArcRotateCamera("ArcRotateCamera", Math.PI / 2, Math.PI / 3, 410, new BABYLON.Vector3(0, 0, 0), scene);camera.lowerRadiusLimit = 70;camera.upperRadiusLimit = 500;And I have this mesh:var testing = BABYLON.Mesh.CreatePlane("testing", 100, scene);testing.rotation = new BABYLON.Vector3(Math.PI / 2, Math.PI, 0);testing.position.y = -20;testing.parent = camera;And I want the mesh to move with the camera when I call the following code:$('#topBorder').on('mouseenter', function() { this.iid = setInterval(function() { scene.activeCamera.target.z -= speed; }, interval);}).on('mouseleave', function(){ this.iid && clearInterval(this.iid);});I thought the mesh would move since I set its parent to camera but it stays in the same place. Any suggestions? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 26, 2013 Share Posted November 26, 2013 Hello, this is because you move the target of the camera (and not its position) Quote Link to comment Share on other sites More sharing options...
zincman320 Posted November 26, 2013 Author Share Posted November 26, 2013 I tried changing scene.activeCamera.target.z -= speed; to scene.activeCamera.position.z -= speed and now nothing moves. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2013 Share Posted November 26, 2013 Try:testing.position.z -= vitesse;or camera.position.z -= vitesse; Quote Link to comment Share on other sites More sharing options...
zincman320 Posted November 26, 2013 Author Share Posted November 26, 2013 I can do testing.position.z and it works when I try camera.position.z everything disappears. I would like to only set the camera position though because I'm trying to add in a UI made of several different components. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 26, 2013 Share Posted November 26, 2013 You give a speed too fast on the camera.try :camera.position.z -= 0.1;orcamera.position.z -= 0.05;Test several speed. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 26, 2013 Share Posted November 26, 2013 The camera is an ArcRotateCamera. Either you change alpha and beta values (to change the rotation) or either youuse cam.setPosition() to compute alpha and beta values for you Quote Link to comment Share on other sites More sharing options...
zincman320 Posted November 27, 2013 Author Share Posted November 27, 2013 That worked, thanks again Deltakosh! 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.