So this code ALMOST works. Basically I have a platform. If the player is below it, he ignores the collision. If he’s above it, or equal to it, it doesn’t ignore it. What happens is, he does ignore it, and when i jump above it, you can see him collide with it for a split second, and then it turns back off and he falls back through it. So my if statements works, but then it turns back off. Any suggestions on a better way to do this?
void FixedUpdate()
{
if(platform != null)
{
if(groundCheck.transform.position.y >= platform.transform.position.y && rigidBody.velocity.y <= 1)
{
ignoreCollision = false;
}
else
{
ignoreCollision = true;
Physics2D.IgnoreCollision(playerCollBox, platformCollision);
Physics2D.IgnoreCollision(playerCollCir, platformCollision);
}
if(ignoreCollision)
{
platformColor.color = Color.red;
}
else
{
platformColor.color = Color.green;
}
}
}