Hi everybody.
I’m making a platformer 2D, and I’ve got a problem with collision detection.
To make my Player jump, I check if it’s on the floor. To check it, I use a raycast from player to Vector3.down with an offset. It works well.
But some of my platforms has a PlatformEffector (then if the player is under the platform, it can jump on it).
The problem is : I can jump when I’m “in” the collider with a PlatformEffector ! I have no idea about how I can avoid it easily. Could someone help me ?
There is a raycasts start in colliders in physics2d settings (which might be ‘queries starts in colliders’ now) that you could turn off, maybe that’s what you are looking for:
Being able to jump while in an effoctor is actually an important feature, which I in part had a hand in notifying Unity about, because when they introduces the effectors there was a bug which prevented any kind of movement away from the surface so any character or object moving over it was kinda stuck like glue. I believe now there is an option on the effector to determine how much the force from the effector is balanced against the force from the object? The alternative is that you could apply a downward force, or disable the user input that would let them jump.
I think this was the SurfaceEffector2D which applied forces that countered forces being applied on a Rigidbody2D to make it jump, move etc; something which I fixed. Maybe that was your bug report, sounds like it.
Not sure if it’d help but you can also use the IsTouching & IsTouchingLayer which both ignore disabled contacts from the PlatformEffector2D i.e. they won’t show you as touching a platform effector if you’re currently passing through it via the one-way option: http://docs.unity3d.com/ScriptReference/30_search.html?q=istouching