Right now my platform with “PlatformEffector2D” is set up that when the player jumps from below the platform and lands on the platform when falling from above it. The usual stuff.
I noticed that the “OnCollisionEnter2D” of the player activates even when the player only touches the box collider of the platform, even from below the platform, when “PlatformEffector2D” doesn’t impact the player in any way.
The problem: I need to know when the player actually lands on the top of the platform and is no longer falling, I don’t need to know when the player and platform colliders touch without affecting one another. Is there any way to know when the platform and the player actually collide?
I don’t have much experience to tell you the right answer but, I think that you can use the “OnCollisionExit2D”.
This method is called when two GameObject aren’t touching anymore.
Let’s imagine that our player jump into the platform and you can use this method to write a code that trigger another collider that represent the floor of each platform. I believe this can works for you.
Are you simply trying to optimize so your not sending calls out constantly?
Or are you trying to have a DoneFalling(){} type of event triggered?
If the first, don’t bother optimizing it as it’s not worth the energy.
If latter, do what RemDust suggested, a great thing I add is a get;set; property to my code called “Falling” as I do the check often throughout my code, on setting Falling to false I can trigger any special effects (dust cloud on landing)
The PlatformEffector2D OneWay feature simply disables the contact so the physics system essentially ignores it but we still perform the callback as various users still find this useful. You can use Collision2D.enabled to check if the contact is enabled or not. When passing through a PlatformEffector2D collider, that property will be false.