Hello!
I have 2 rigid bodies being moved around my scene by setting their linear velocity. I dont want them to be able to be pushed by each other when they collide (or being pushed by any other rigid body, for that matter). How do I go about this?
Thanks!
Preventing Rigid Bodies from being pushed
-
- Posts: 5
- Joined: Sun Mar 08, 2015 2:31 pm
Re: Preventing Rigid Bodies from being pushed
Set mass to 0, recalculate inertia and set them with btRigidBody::setMassProps(btScalar mass, btVector3 inertia)
This will make them kinematic, now they cannot be affected with any force, even gravity.
This will make them kinematic, now they cannot be affected with any force, even gravity.
-
- Posts: 3
- Joined: Mon Mar 30, 2015 5:00 pm
Re: Preventing Rigid Bodies from being pushed
I understand setting the mass to 0 will make them immovable, however Im still trying to have them not only be affected by gravity, but be moveable from setLinearVelocity too. I just want them to be unable to push each other. Using setMassProps to set the mass to 0 then back to the previous mass doesnt prevent this either.RazzorFlame wrote:Set mass to 0, recalculate inertia and set them with btRigidBody::setMassProps(btScalar mass, btVector3 inertia)
This will make them kinematic, now they cannot be affected with any force, even gravity.
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: Preventing Rigid Bodies from being pushed
0 mass means not dynamic, not necessarily immovable. Basically anything they do affects dynamic objects but not the other way around. In fact, other kinematic objects don't affect it either.Adman wrote: I understand setting the mass to 0 will make them immovable
What is gravity? It's just a constant acceleration (for what you want), which is the same as just linearly increasing velocity. setLinearVelocity can simply take in your current velocity + a gravity constant for your simulation rate + your externally derived velocity change. You'll end up with an object that moves according to what you want, which falls due to gravity, and isn't affected by anything else but still pushes dynamic objects. Just make sure to take care of your own collision and restitution or you'll be falling through the floorAdman wrote: however Im still trying to have them not only be affected by gravity, but be moveable from setLinearVelocity too. I just want them to be unable to push each other. Using setMassProps to set the mass to 0 then back to the previous mass doesnt prevent this either.
-
- Posts: 3
- Joined: Mon Mar 30, 2015 5:00 pm
Re: Preventing Rigid Bodies from being pushed
I tried this, every time I set the mass to 0, I cant move it via setLinearVelocity. Am I doing something wrong?Basroil wrote:setLinearVelocity can simply take in your current velocity + a gravity constant for your simulation rate + your externally derived velocity change. You'll end up with an object that moves according to what you want, which falls due to gravity, and isn't affected by anything else but still pushes dynamic objects.
-
- Posts: 463
- Joined: Fri Nov 30, 2012 4:50 am
Re: Preventing Rigid Bodies from being pushed
Try this: http://bulletphysics.org/mediawiki-1.5. ... tic_BodiesAdman wrote:I tried this, every time I set the mass to 0, I cant move it via setLinearVelocity. Am I doing something wrong?Basroil wrote:setLinearVelocity can simply take in your current velocity + a gravity constant for your simulation rate + your externally derived velocity change. You'll end up with an object that moves according to what you want, which falls due to gravity, and isn't affected by anything else but still pushes dynamic objects.
Kinematic bodies are a bit more work intensive than dynamic ones for setup, but the tradeoff is that you can control exactly what it does.