Quantcast
Channel: Questions in topic: "ignorecollision"
Viewing all articles
Browse latest Browse all 148

Physics2D.IgnoreCollision not triggering properly

$
0
0
I have a code where I want to be able to jump from under a platform above the platform and be able to land on top of it. My trigger is a little lower and wider than the collider to allow me to do this properly. void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.name == "Player") { Debug.Log("Platform Disabled"); Physics2D.IgnoreCollision(platformCollider, playerCollider, true); } } void OnTriggerExit2D(Collider2D other) { if (other.gameObject.name == "Player") { Debug.Log("Platform Enabled"); Physics2D.IgnoreCollision(platformCollider, playerCollider, false); } } In this current configuration, the platform collider will be disabled, but it will not be re-enabled, so I can jump through it, but I won't land back on it (At the start, I am able to land on it, so the collider does work). The Debug.Log outputs for both so I know it is triggering properly. The weird glitch is if I switch the true and false values around, and I land on top of the platform, it will rapidly vibrate between the trigger and collider, enabling and disabling the platform rapidly as the character enters and exits the trigger. So basically, the first Physics2D.IgnoreCollision can turn the collider on and off, and the second Physics2D.IgnoreCollision is only able to turn it off, not back on.

Viewing all articles
Browse latest Browse all 148

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>