Anybody know a better way to do this? I’d love to hear your idea. Here’s how I’m doing it:
I’ve got a script that causes my player object’s rigidbody to be able to pass through platforms that he’s jumping up to. Basically, it works by checking to see if the player’s y position is less than or greater than the platform. It’s a simple fix. But because a platform’s position is technically at the center of it’s bounding box, and a rigidbody’s position is technically the center of ITS bounding box, my script doesn’t work properly when my player attempts to jump into the platform from the upper corner–since the script detects that the y position of the rigidbody is higher, and therefore the platform should be solid.
So, I think my problem is that I can’t use contact point normals to detect a player’s point of entry to a trigger because you can’t get those when you’re just using OnTriggerEnter. Is this correct?
Help!
Here’s my script:
var floorOfPlatform;
var playerObject;
function Start()
{
if(gameObject == "puzzlePlatformTrigger")
{
floorOfPlatform = gameObject.transform.parent.gameObject.transform.Find("puzzleFloor");
}
if(gameObject == "jumpThroughTrigger")
{
floorOfPlatform = gameObject.transform.parent.gameObject.transform.Find("basicPlatform");
}
if(floorOfPlatform == null)
{
floorOfPlatform = gameObject.transform.parent.gameObject.transform.Find("Puzzle Platform Floor");
}
playerObject = GameObject.Find("playerRigidBody");
}
function OnTriggerEnter(other: Collider)
{
if(playerObject.transform.position.y < floorOfPlatform.transform.position.y)
{
Physics.IgnoreCollision(playerObject.collider, floorOfPlatform.collider, true);
}
}
function OnTriggerExit()
{
Physics.IgnoreCollision(playerObject.collider, floorOfPlatform.collider, false);
}