Official Python bindings with a focus on reinforcement learning and robotics.
- Posts: 1
- Joined: Sun Dec 09, 2018 5:10 am
I have created a rigid body in a world without gravity and created a sphere shape. I assign a vector3 as a way point and use applyForce in the direction of the way point. This is working and my model is moving around. My questions are about how to rotate toward the destination while force is being applied. The end result should be if I give the body a way point it applies force and rotates around until facing the direction of the way point while moving forward the whole time.
The only example of this I could find was viewtopic.php?f=9&t=12309&p=41319&hilit ... ile#p41319
I was unable to find a getLocalInverseZAxis method in my graphics engine. I don't understand what it should do either.
Code: Select all
ENG_Vector4D missileDirection = missileProperties.getNode().getLocalInverseZAxis();
Code: Select all
btVector3 missileDirection = newMissileDirection - mShipNode->getPosition());
but the result was a constant rotation around the one axis I used setAngularVelocity on.
My cosAngle is never greater than 0.99. I had to set to 'if (cosAngle > 0.09)' to get the rotation I am getting.
- Posts: 527
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
I recently replied to a similar question and supplied one way to do it
. Maybe it will work for you.
The short overview:
Pick a timeScale > substep timeStep
Compute the rotation you need: angle and axis.
if angle < someSmallThreshold: angularVelocity = <0,0,0>
else: angularVelocity = (angle * timeStep / timeScale) * axis
Note: slamming the velocity will override effects of external collisions. If that is what you want: great. Otherwise you need to be trickier, maybe apply impulses.