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

Problem passing through bottom of platform

$
0
0
I created a script that checks if any platforms with the pass platform tag enters a collider surrounding the player object. Then I store the platforms in a list and ignore collision between all the parts of player and them if the players lowest point is less than the platforms position and do the opposite if its greater. Problem is it only works sometimes. Even though the players bottom most point is greater than the platform it still falls through it. Here's the code I use for it in update. //run through all plats to see if collision with them should be ignored or not foreach (Collider2D plat in plats) { //if bottom most point is higher than highest point of plat if ((bmllp > plat.transform.position.y && gi == false) || (bmllp < plat.transform.position.y && gi == true && GetComponentInParent().velocity.y >= 0)) { //dont ignore collision between all parts and plat foreach (Collider2D p in parts) { Physics2D.IgnoreCollision(p, plat, false); } } else { //ignore collision between all parts and plat foreach (Collider2D p in parts) { Physics2D.IgnoreCollision(p, plat, true); } } } I think it might have something to do with the platform being too thin, since when I increase the platforms size the desired result seems to be more consistent. But I would prefer to keep the platform thin, any advice on what to do would be appreciated.

Viewing all articles
Browse latest Browse all 148

Trending Articles



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