I’m trying to check a collision rotation to find what face of an object is being hit. I’m using transform.up, transform.forward, and that works.
// Handles object collision with Cube.
void OnCollisionEnter(Collision collision)
{
// Creates a direction we have been hit from.
Vector3 normal = collision.contacts[0].normal;
// Checks whether object is valid and whether it's already been used. Returns true if okay.
if(collision.collider.GetComponent<FallingObject>().CheckAndDestroy())
{
// Checks to see if collider was Moon.
if(normal == transform.forward)
{
I need to check if it’s within a certain range of the rotation, not the exact number. If it was vector distance I’d know, but I don’t know how to measure the difference between two rotations.
I noticed from your last post you express tough love lol :P. I studied for a few hours and understood that I needed the dot product ‘Vector3.Dot()’. Multiplying two vectors together to normalise them and using the Cosine between the two to find a scaler between the two. 1.0 being the same direction, 0.0 being adjacent, and -1.0 being the opposite…
From that I actually found the correct answer myself. Thanks Jessy. I’m a fan of learning myself so long as I’m given some guidance in the right direction of where to look.
Man, I don’t know what you guys are talking about! I just thought Unity provided a really good introduction to what you were asking about in their documentation.