Find Normal Vector to BoxCollider
Hi Guys, I'm quite new with Unity and I'm trying to understand the basic concept and doing some try. Unfortunatelly I got stuck trying to find the normal vector of a boxCollider.
private void updatePosition()
{
BoxCollider collider = testRacket.GetComponent<BoxCollider>();
Vector3 colliderPosition =collider.transform.position;
Quaternion colliderRotation = collider.transform.rotation;
Vector3 colliderCenter = transform.TransformPoint(collider.center);
//The cube with the position that I'm trying to replicate
colliderNormalCube.transform.position = colliderCenter;
colliderNormalCube.transform.rotation = colliderRotation;
Vector3 normalFromColliderCenter = (colliderRotation * colliderCenter);
Debug.DrawLine(colliderCenter,normalFromColliderCenter*100,Color.blue);
Debug.DrawLine(colliderCenter, colliderCenter*100,Color.yellow);
Debug.DrawLine(colliderCenter, Vector3.Cross(colliderCenter,Vector3.up),Color.red);
}
I tried to create a cube of specific size and put it in the center of the Racket Collider and rotate it accorging to the collider rotation. And it worked well... What I'm trying to do now, is to draw a debug line for the same stuff but I'm stuck. I read a lot in the blog a did some try but none worked... What do I miss?
collidernormal.png
(92.3 kB)
Comment