- Home /
Vector3.Reflect - object bounce
I have an object that moves around a scene: rigidbody.AddForce(Vector3(1,1,0)); is how I am moving this object. The scene has a number of cubes randomly placed in it. I want the object to bounce off these cubes and keep moving.
the Vector3.Reflect takes 2 arguments: Reflect (inDirection : Vector3, inNormal : Vector3)
what do I enter for inNormal?
Answer by robertbu · May 09, 2013 at 05:14 AM
Objects bouncing or not bouncing is an issue of the physics material of the objects. Vector3.Reflect() will not make them bounce. Vector3.Reflect() simply takes a vector (a mathematical construct) returns a vector. A normal vector is a vector perpendicular to a surface, so inNormal is the normal of he surface the ray is being reflected against. If you need the normal and know the direction an object is moving, you can use any version Physics.Raycast() that takes a RaycastHit as a parameter. RaycastHit returns the normal of the surface it hits.
Note a simple Vector3.Reflect is an imperfect method of determining the direction of an object after a bounce.
Your answer
Follow this Question
Related Questions
Vector3.Reflect - wrong direction 5 Answers
How do you keep a bouncing ball from "breaking" through cloth 1 Answer
Help me bounce (make player bounce when landing from a jump) 0 Answers
pong question 2 Answers
Objects bouncing when change texture 0 Answers