Hi, I am firing a missile in my game. But, it is doing some problem. Missile collides a collider but it does not move in the normal direction of collider after colliding the border. I have attached image. In image black line is showing the direction of missile moving towards collider. Green line is the direcion in which missile sholud move after colliding. Red line is that line in which missile is moving currently after colliding.
I am using following code:
function OnCollisionEnter (collision : Collision)
{
for (var contact : ContactPoint in collision.contacts)
{
moveTowards = contact.normal;
rigidbody.AddForce(moveTowards*speed);
}
}
function Update ()
{
rigidbody.AddForce(moveTowards*speed);
}
Waiting for your help in order to remove my error;