Collision angle of collided

Hi all,

I’m using :

OnControllerColliderHit (ControllerColliderHit hit)

I wish to align my collider with the angle of the face it collided with on the collision object.
Let me explain better :slight_smile:

Suppose a body collides with a cube; irrespective of it’s collision angle I wish it to rotate to be flush with the cube’s side i.e. so it matches the cube’s collided with face angle - sorry, not a great explanation!

Hope that’s clear enough for someone to help. I was thinking that somehow I get the dot product of the collision and then use that somehow to align the collider with the cube’s face - but not sure…

Cheers

If you want to get the rotation between the two points in space, cube and a sphere, you should use something like this:

OnControllerColliderHit(hit : ControllerColliderHit)
{
   Cube1.rotation = hit.collider.transform.Vector3 - Cube1.Vector3;
}

If you want more information about aligning faces to other ones, there is a nice Faux/Spherical script on the forums, 1.

– David