What is a good way to handle phasing through colliders when jumping in a 2D platformer?

Godot Version

4.2.2

Question

What is a good way to handle phasing through colliders when jumping in a 2D platformer?

Context

I’m fairly new to Godot. I’ve been running into an issue that has been driving me nuts. It’s probably something simple that I’m not getting.

I’m making a 2D platformer and I’m trying to write some code that will re-enable a collider when I phase through a platform. I’m using a hitbox collider for detection and a feet collider to handle the actual physics of landing on a platform.

Outside of the excerpt I share below, my code has logic that involves applying a force to the player and disabling the “_feet_collider” variable upon applying this force

Here is my code:

func _ready():
_hitbox.body_exited.connect(_exit_feet_collider)
_hitbox.body_entered.connect(_entered_feet_collider)
pass

Code below doesn’t work for some reason

func _exit_feet_collider(body):
if body.collision_layer == 1 and _feet_collider.disabled:
if jumping:
print(“feet collider enabled”)
_feet_collider.disabled = false

func _entered_feet_collider(body):
if body.collision_layer == 1 and _feet_collider.disabled:
print(“collider is disabled!”)

###########################
The odd part is that I’m using the collider debug mode to visualize when the _feet_collider is disabled or not, and when I run the game I can see that the feet collider is enabled when it is needed, yet the player still phases through the platform.

Any alternative suggestions or advice would be greatly appreciated. Thank you!

What is your goal? Describe the “phase through the platform” and the exact purpose of the hitbox collider and the feet collider, it would be helpful to provide images or videos, and code sections formatted with

```gdscript ← This specifies these are GDScript
write or paste your code here
```

Hi. I’m sorry for the late response. I have come up with a solution on my own that works, it just isn’t as clean as I would have wanted. So the problem is solved.

I’m not sure how to delete this post or close the thread. Regardless, thank you for replying and your willingness to help! :slight_smile: