cpu_sam Posted January 23, 2018 Share Posted January 23, 2018 Hello, I'm trying to rotate a mesh with mesh.rotate(BABYLON.Axis.Y, 0.1, BABYLON.Space.LOCAL) but like it's attached to a physicsImpostor the impostor not rotate, only the mesh. And so, I'm trying to do this movement: http://playground.babylonjs.com/#NFJFE Following the example to my mesh go ahead I must rotate a little and move on the axis target (like Z is the front), but the "obvious" code about not works with impostor, and I supose that I should rotate it to make the same effect of the air plane's link. I'm a 2d programmer and trying to learn 3d with babylonJS, I still not learn about quaternions (planning to see so on) Thanks for any help. NOTE: I've searched in google many times but no luck Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 23, 2018 Share Posted January 23, 2018 https://www.babylonjs-playground.com/#2ADVLV#4 Quote Link to comment Share on other sites More sharing options...
cpu_sam Posted January 23, 2018 Author Share Posted January 23, 2018 Thank you for your help Prime8. Well, let me explain better. For example: I have a block in the position (0,0,0), for default I use the local axis Z (positive) as the front of object. When I run block.rotate(BABYLON.Axis.Y, 45 degrees, BABYLON.Space.LOCAL);//45 degrees just for calc So the front of object stays in 45 degrees, and the movement of block should be in 45 degrees when move with block.position.z += 1, and not just in the axis Z, but will be in two axis (X and Z). Like this example of air plane: http://playground.babylonjs.com/#NFJFE My problem is: I cannot move in that way (in X and Z when rotate the front in Y axis), the block just follow the world axis instead of follow the local rotate axis o block (follow the front of it) So, I think that impostor wasn't rotate, but just the mesh. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 23, 2018 Share Posted January 23, 2018 A PG showing what is going on with the method you are trying would help. Quote Link to comment Share on other sites More sharing options...
cpu_sam Posted January 24, 2018 Author Share Posted January 24, 2018 Ok, I will make two example. Just give me some time. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 24, 2018 Share Posted January 24, 2018 Then I will help ^_^. Quote Link to comment Share on other sites More sharing options...
cpu_sam Posted January 24, 2018 Author Share Posted January 24, 2018 Man, I solved the problem hehehe I was remade the example and studying the air plane example and I notice that in the air plane example they don't move like this: airPlane.position.z += 1; but they use the translate method, like this: airPlane.translate(BABYLON.Axis.Z, speed, BABYLON.Space.LOCAL); For now, thank you Pryme8 and I will let my example here in the case of some one need (attached) 3dMovement.zip Pryme8 and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 24, 2018 Share Posted January 24, 2018 Hi cpu_sam... and P8. Sam, mesh that have impostors... are sometimes "moved" with applyImpulse() or setLinearVelocity(). There are also physics springs and motors that can translate a mesh-with-impostor. https://www.babylonjs-playground.com/#15AFCG#24 There's a little applyImpulse playground. WASD keys for the camera nav. Arrow keys for impulses. There is a small amount of friction on ground and box, so, box has SOME tendency to tip. Here is the same playground... except it uses setLinearVelocity. https://www.babylonjs-playground.com/#15AFCG#25 Rotations can be done with setAngularVelocity(), or, you can use a fancy 2-impulse "twist" method, too. One more? Ok. https://www.babylonjs-playground.com/#15AFCG#27 Here, I am using the arrow keys to do various 'rotate' and 'translate' commands, making sure the physics impostors are staying sync'd. Looking good. I think you have a good solution. I downloaded, unzipped, and looked-over your scene (thx for providing that zip). I believe it's ready for physics-enabled. Looks good. Fun experiments ahead for you. Welcome to 3D, BJS-style. You're doing great. cpu_sam 1 Quote Link to comment Share on other sites More sharing options...
cpu_sam Posted January 24, 2018 Author Share Posted January 24, 2018 5 hours ago, Wingnut said: One more? Ok. https://www.babylonjs-playground.com/#15AFCG#27 Cool example man, I still not tried to move with impostor, but surely I will study your example. Thank you. Wingnut 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.