I am trying to make a projectile that when colliedes with a surface at a 45 degree or lower will bounce and keep moving. I was trying to implement that with this code, but sadly I can’t get it to work.`if (bounce){
// Reflect the trajectory of the contact
var reflected : Vector3 = Vector3.Reflect( transform.forward, collision.contacts[0].normal );
// Compare how alike the reflection and the original direction are
if ( Vector3.Dot(reflected, transform.forward) > 0.5 ) {
// Do bounce logic
} else {
// Do not-bounce logic
}
It’s a little hard to tell without more code, but the first thing I notice is that your first line there is measuring the angle between the forward vector of the projectile (assuming this script is attached to the projectile) and the normal of the collision. If I’m not mistaken, the collision normal is perpendicular to the surface, which means the angle you want is (90 - angle), not angle itself.