- Home /
[newbie] Vector3.Reflect not working properly. Please help
I created a script that when a bullet hits a gameobject with a tag "environment", it should bounce/reflect. It works fine on some gameobjects but for some gameobjects the bullet gets stuck on their collider and doesn't bounce. I made sure that all of the objects are tagged. What could I be missing?
void Update(){ direction = newPos - oldPos; } void OnHit(RaycastHit hit) { Quaternion rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.transform.tag == "Environment") { newPos = hit.point; if (bounce) { Vector3 reflect = Vector3.Reflect(direction, hit.normal); transform.forward = reflect; } }
Your answer
Follow this Question
Related Questions
Object's vectors are not moving with the object, what did i do wrong? 1 Answer
Boxcast vs Raycast Oddities 1 Answer
Unity3d find angle/direction of a Ray / Raycasthit 1 Answer
How to convert one axis to world space? 1 Answer
Can someone explain how this piece of code from third person prefab works ? 0 Answers