Hi, I’m trying to find what side of the object my projectile collides with, can someone please tell me where I’m going wrong, this is what I thought would tell me, thanks.
function OnCollisionEnter(collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var relativePosition = transform.InverseTransformPoint(contact);
if(relativePosition.x > 0){
print ("The object is to the right");
}else{
print ("The object is to the left");
}
if (relativePosition.y > 0) {
print ("The object is above");
}else{
print ("The object is below");
}
if (relativePosition.z > 0) {
print ("The object is in front");
}else{
print ("The object is behind");
}
}
Thanks for the input but it's not printing the correct side every time, I've attached a box collider to the Mech for testing and fire a RPG at it, and sometime it prints the correct side! [9891-grab-01.jpg|9891]
– GriffoThe script is attached to the big robot?
– fafaseOnce again thank you, that works perfectly ..
– GriffoSorry another problem has arisen, if I hit the Mech below the red line it prints out, "On The Back" but if I hit it above the red line it prints out "Right", also if the Mech is facing me, hit below the line it prints out "In Front" but hit above the line it again prints out "Right" ![alt text][1] [1]: /storage/temp/9914-grab-01.jpg
– GriffoIf anyone else has this problem I went this way - http://answers.unity3d.com/questions/248830/collision-surface-check.html
– Griffo