Detect collision from a particular side
- by Fabián
I'm making a platform sidescrolling game. All I want to do is to detect if my character is on the floor:
function OnCollisionStay (col : Collision){
if(col.gameObject.tag == "Floor"){
onFloor = true;
} else {onFloor = false;}
}
function OnCollisionExit (col : Collision){
onFloor = false;
}
But I know this isn't the accurate way. If I hit a cube with a "floor" tag, in the air (no matter if with the character's feet or head) I would be able to jump.
Is there a way to use the same box collision to detect if I'm touching something from a specific side?