- Home /
Set velocity of kinematic rigidbody appropriately
So I'm moving kinematic rigidbodies via scripting and I want their velocity to be set appropriately as they move. Right now, if they touch other physics objects, they should influence them after touching/give them momentum, but I can't get it to work.
When I try to set the velocity value in the script that moves the object, I get the following error:
Actor::setLinearVelocity: Actor must be (non-kinematic) dynamic!
Which seems to be a PhysX error, but also kind of bullshit, since the only other understandable solution to this issue (kinematic rigidbodies automatically adjust their velocity with changes in position) doesn't seem to be the case.
I can think of other ways to get around this issue, but by far the BEST solution would be to just have the rigidbody's velocity value work correctly.
How can I get this to work?
I have been trying to accomplish something similar.
The traditional definition of kinematic is an object with a inverse inertia tensor of 0 (i.e. infinite mass). This is fairly easy to implement in a physics solver, and velocity can be trivially taken into account.
Emulating it with a very heavy object whose position and velocity are set in fixed update should be a possibility, but for me this seems to kill performance.
$$anonymous$$ Wu
Answer by JoaquinRD · Aug 17, 2013 at 05:21 PM
Kinematic rigidbodies are unaffected by physics, so they cannot have a velocity because that is in the realm of physics. Use transform.Translate instead.
$$anonymous$$inematic rigidbodies can collide with physics objects/stop their collisions, no? That's not exactly true that they're unaffected by physics. Since they can affect other things, using their velocity to apply impulses seems to be an obvious use of is$$anonymous$$inematic to me.
$$anonymous$$inematic rigidbodies are unaffected by physics. Actually, a kinematic rigidbody is taken into account by the collision system only for limited purposes: it can wake up a sleeping rigidbody on collision, and can make a moving trigger work fine.
If you move a simple object (without a rigidbody) by altering its position, its collider passes through sleeping rigidbodies; if it has a kinematic rigidbody, however, the sleeping rigidbody wakes up and reacts to the penetrating collider with the penalty force - this isn't a regular collision, where both rigidbodies have their velocities altered: the kinematic one isn't affected.
Your answer
Follow this Question
Related Questions
Problem Trying to Apply Non-Kinematic Velocity to Rigidbody 0 Answers
how to create Magnetic repulsion ? 0 Answers
Hooking RigidBody.AddForce 0 Answers