- Home /
Updating Velocity for a Rigidbody Collision
I am making a brickbreaker type of game and have the ball and bricks modeled as a rigidbody. The velocity of the ball is set in a script and is added to transform.position every update. When the ball collides with a brick, it correctly reflects away for one frame but then my script takes over and redirects the ball back toward the brick because the velocity was never changed. Is there a way for me to take advantage of the accurate built in collisions while also controlling velocity when it is not colliding?
Answer by testure · Jul 17, 2011 at 06:39 AM
That helps, but the only problem is that in order to use that, my rigidbody can't be kinematic which means it won't react to the collisions with the bricks.
what? if a rigidbody is kinematic, it doesn't respond to physics at all.. what you've just said is backwards.
A kinematic rigidbody can affect other rigidbodies that are not kinematic, but not vice versa.
From the docs:
**Is $$anonymous$$inematic**: If enabled, the object will not be driven by
the physics engine, and can only be manipulated by its
Transform. This is useful for moving platforms or if you want to
animate a Rigidbody that has a HingeJoint attached.
I did say it kind of backwards. What I meant was that in order to use rigidbody.velocity, the ball has to be kinematic. However, if it is then it won't react to the collision with the bricks. So, I need to be able to set its velocity but then allow it to react to physics