Nabroski Posted May 30, 2016 Share Posted May 30, 2016 Hello I got a 3dModel of an elevator. I trigger a button for it's position with the following code: myMesh.actionManager.registerAction(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPickTrigger, myMesh,"position.y",-2.6, 1000)) //down .then(new BABYLON.InterpolateValueAction(BABYLON.ActionManager.OnPickTrigger, myMesh,"position.y",0.001, 1000)); //up Witch works great! Accept when my char wants to get up again, he is falling through the ground, - the mesh. Few workarounds that come into my head, like check the state of the "event" an apply new gravity or new cam position. What's the easiest one? Any suggestions are highly appreciated! Best Quote Link to comment Share on other sites More sharing options...
dbawel Posted May 30, 2016 Share Posted May 30, 2016 @Nabroski- Do you have a Playground scene or a URL where we can review? Otherwise, it's difficult to know the reason for your character's behavior. DB Quote Link to comment Share on other sites More sharing options...
Nabroski Posted May 31, 2016 Author Share Posted May 31, 2016 Hello here is the code i use. working from blender to a web page so my .babylon file has already all parameters like collision, cam etc. accept the elevator thing everything works great.http://www.babylonjs-playground.com/#50KHY#7 thank you so far. Quote Link to comment Share on other sites More sharing options...
Steffen Posted May 31, 2016 Share Posted May 31, 2016 @Nabroski-Hi Nabroski. Very interesting playground. But neither the up movement nor the down movement is working right I think. At least in this playground. It seems that the camera does not update its collision status. I think you have to use the "moveWithCollisions()" call to update the position. Maybe these links could help: http://playground.babylonjs.com/#1NQTNE#11 and the corresponding thread here: Another opportunity is to move the cam (=your character) synced with the elevator. Like this: scene.registerBeforeRender(function () { if (xDown) { elevator.position.y -= 0.01; camera.position.y -= 0.01; } }); Here is a quick and dirty example: http://playground.babylonjs.com/#21GEQY Of course you need to implement some more checks to know whether your cam is in the elevator right now and when to stop and so on. I think this is the easiest way in your case. Maybe you could use the physics engine with cannon or oimo. But this could be oversized. I'm still new to babylon, sorry if I'm misleading and correct me if I'm telling crap ;-) Nabroski 1 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted May 31, 2016 Author Share Posted May 31, 2016 Hello Thank you for you help yes, - moveWithCollisionsis worth a try! and this works perfect for my case: http://www.babylonjs-playground.com/#50KHY#11 Best dbawel 1 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.