Hello,in my game rigidbody moves vertically across xy plane colliding with walls. When rigidbody collides with walls at required velocity it destroys them. My problem is that i do not want my rigidbody to destroy walls when it moves horizontally.
Is it possible to calculate object velocity relative to one dimension? Or there another, more simple solution?
Thanks.
rigidbody.velocity is a Vector3. SO you can access the x, y, and z components of your rigidbody’s velocity.
i.e
var xVelocity = rigidbody.velocity.x;
If you have a character controller on your player, you might be able to read the velocity from there. Here’s a wild guess:
var character : CharacterController;
if(character.velocity.y > 0)
{
//do something
}
or without character controller perhaps like this:
if(gameObject.rigidbody.velocity.y > 0)
{
//moving on y axis
}