Hi there.
I’m trying to make my bullets richochet after hitting walls. I am using Vector3 Reflect. And it works as long as I work with raycasts. However I have no idea how to set new object’s rotation in order for it to move in new direction
private void OnCollisionEnter(Collision collision)
{
ContactPoint contacts = collision.contacts[0];
Vector3 reflectDir2 = Vector3.Reflect(transform.forward, contacts.normal);
//transform.rotation.SetFromToRotation(transform.forward, Mathf.Deg2Rad * reflectDir2);
//transform.rotation = Quaternion.FromToRotation(Quaternion.ToEulerAngles(transform.rotation), reflectDir2);
}
I’ve tried many possibilities, I’ve read dozens of topics but I couldn’t make anything work. What may be the cause, How should I approach this?
This is how it looks at the moment
.