ewanvalentine Posted September 18, 2016 Share Posted September 18, 2016 Hi folks, My first post on the forum, so hello all! I'm been playing around with babylonjs. My intention is to make a Red Alert style game, mostly just to improve my JS skills, and learn the basic concepts of game development etc. However I've struggled to find a best approach for moving meshes around a ground plane. I'm essentially trying to animate a block to move from a selected mesh's initial point, to a selected point. But the movements happen immediately, and feel 'buggy' in my example: http://www.babylonjs-playground.com/#OYE6Q Any help much appreciated! Cheers, Ewan Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 18, 2016 Share Posted September 18, 2016 Hello, Welcome on this forum ! Here is your example: I used animations in order to make the box moving.http://www.babylonjs-playground.com/#OYE6Q#1 And for the fun, I used an easing function here:http://www.babylonjs-playground.com/#OYE6Q#2 Cheers! Quote Link to comment Share on other sites More sharing options...
ewanvalentine Posted September 19, 2016 Author Share Posted September 19, 2016 12 hours ago, Temechon said: Hello, Welcome on this forum ! Here is your example: I used animations in order to make the box moving.http://www.babylonjs-playground.com/#OYE6Q#1 And for the fun, I used an easing function here:http://www.babylonjs-playground.com/#OYE6Q#2 Cheers! Thank you so much! That's much smoother, that makes a lot of sense. One issue I'm having now, using animate. Is that, if I have a static mesh with 0 mass, other meshes can pass through them, if that makes sense... http://www.babylonjs-playground.com/#OYE6Q#4 In that example, you can move the moveable mesh through the static mesh, instead of avoiding it. I tried a few different things, but couldn't find a clear cut answer anywhere. Any help greatly appreciated! Cheers, Ewan Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 19, 2016 Share Posted September 19, 2016 The problem with animations in this case is that the physic engine is not updated. You cannot directly use animations with physics objects because the physics engine has to control and apply constraints where animations just blindly force the position to a specific value Quote Link to comment Share on other sites More sharing options...
ewanvalentine Posted September 20, 2016 Author Share Posted September 20, 2016 @Deltakosh I understand what you're saying, that makes a lot of sense. What would you suggest instead? Some people I've seen use `applyImpulse` but that seems to make my meshes fly around erratically. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 20, 2016 Share Posted September 20, 2016 ApplyImpulse is the natural way to interact with physic objects. You can think about using really small forces to move your mesh for instance. You can also think about synchronizing your mesh on every frame (need to be tested) with mesh.updatePhysicsBody() 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.