I have a game like Doodle Jump, where character is jumping on platforms.
I want to ignore collisions, when the character is flying up and collides with platform. I guess I can take characters Y velocity and if it is positive, disable collisions with all platforms.
But how do I check if there is no platform intersecting my character when the velocity changes from positive to negative, and ignore that collision too?
I guess easiest way would be adding trigger collider to you character. Make it wider along y axis, especially top side. And code something like this
void OnTriggerEnter(Collider col){
if (/*character y velocity*/ >= 0)
Physics.IgnoreCollision(/*character nontrigger collider*/, col);
}
void OnTriggerExit(Collider col)
{
Physics.IgnoreCollision(/*character nontrigger collider*/, col, false);
//you can also make list of ignored colliders and do checks
}