Description
The Normal
field in the PhysicsContact
struct represents the normal vector at the point of contact during a physics collision. This vector is typically a unit vector that is perpendicular to the surface at the contact point, indicating the direction of the force applied during the collision.
Usage
Use the Normal
field to determine the direction of the contact force in a collision. This can be useful for calculating reflections, applying forces, or determining the orientation of objects after a collision.
Example
// Example of accessing the Normal field in a PhysicsContact instance
PhysicsContact contact = GetPhysicsContact();
Vector3 normalVector = contact.Normal;
// Use the normal vector to calculate a reflection vector
Vector3 incomingVector = new Vector3(1, 0, 0); // Example incoming vector
Vector3 reflectionVector = Vector3.Reflect(incomingVector, normalVector);
// Apply the reflection vector to an object's velocity
GameObject myObject = GetGameObject();
myObject.Velocity = reflectionVector;