setAngularVelocity problems

setAngularVelocity problems

Hi, we're trying to set the angular velocity of a rotating object, the problem is that it's not responding very well. We're setting the angular damping to 0 after which we try to set the velocity with setAngularVelocity(). The problem is that there's some kind of threshold before it starts to spin at all, and when that is reached it starts to spin to fast. It's as if there's inertia affecting the angular velocity and we're trying to apply impulses each frame.

Also, I have another little question here, we're trying to get a rigid body to act as a grab volume by having it another collision layer and then creating constrains to it. Since we don't want this rigid body to be affected by the mass of the player we do a setTransform( staticFixedRootRigidBody->getTransform() ); each frame, this doesn't prevent the grab volume from still being affected by the mass of the player though. I'm thinking this have something to do in which order the solver solves the constraint vs the setting the transform, but I'm not certain since we don't have the source.

Grateful for any help!

7 帖子 / 0 全新

Hi Sairon,
The first one sounds strange - can you change one of the demos to reproduce the behavior with setAngularVelocity() and post it here? Something simple (like SimpleShapesDemo.cpp) is probably the easiest. It sounds like the body isn't getting activated properly, although setAngularVelocity should reactivate it.

For the second one, can you set the grab volume to keyframed motion type (instead of fixed or dynamic)? That way it will never move unless you tell it to (preferably with hkpKeyFrameUtility::applyHardKeyFrame). If you need it to respond to other things, just not the character, that's a little trickier (but should still be possible)...

FYI, what I think is happening (as you described it) is that the grab volume gets moved by the constraint solver, then warped back into place when you call setTransform. Setting the transform doesn't change the velocity of the body, though, so you probably end up with both the grab volume and the character jittering.

Hope that helps...


Hey Sairon,

Could you show how you're using setAngularVelocity()? Are you calling it every frame or just once?

As far as your "grab volume", have you considered using a phantom for this? A phantom is a rigid body that "collides" with the world, in that contact points are generated, but these collisions don't actually effect forces on colliding bodies. This volume can follow a rigid body by setting its position (and rotation if you want) every frame, either in your main loop or via a custom action.


Oops, didn't see Chris's reply get in there first. Hope one of our responses helps you out :-)


Thanks, I will be sure to check these things out right away. I've tried setting the angular velocity both once per time step, and only once in the beginning. The reason for why I went with a rigid body instead of a phantom is that I didn't find any possibility to create a fixed constraint between a phantom and the player rigid body.

Hi Sairon,

You won't be able to use a constraint but you can use an action to set the position of the phantom to the position of the rigid body that you're trying to follow.


You can see some Actions in action (sorry) in these demos:

UnaryAction is probably the one you're looking for.