+1 vote

I have a OneWayWall scene which has the following node structure:

Node2D > StaticBody2D > CollisionShape2D

TheCollisionShape2Dhas one_way_collision set to true.

I want my player to be able to drop down through this shape when

Input.is_action_pressed("down") and Input.is_action_just_pressed("special")

So, my question: What is a good way of allowing players to drop through one way platforms?

In the past, I've set a dropping bool to true and ignored collisions until it was changed to false a few milliseconds later. But I don't know how to ignore collisions for one way platforms in Godot.

in Engine by (1,571 points)

2 Answers

+4 votes
Best answer

One way is to track them and use collision exceptions that are available on all physics bodies.

A pseudo code algorithm for handling many temporary exclusions might look something like this:

extends KinematicBody2D # Player Class probably

const PLATFORM_EXCL_TIME = 10/60.0 # 10 frames

var exclusions = []

func drop():

    var platform = get_platform()

    exclusions.append({ platform = platform, duration = PLATFORM_EXCL_TIME })

func _fixed_process(delta):

    var active_exclusions = []

    for exclusion in exclusions:

        exclusion.duration -= delta

        if(exclusion.duration <= 0):


    exclusions = active_exclusions
by (5,242 points)
selected by
+6 votes

If you are using a KinematicBody2D for your player:

self.position = Vector2(self.position.x, self.position.y + 1)

Did the trick for me

by (29 points)

This worked for me too, super easy.

Me as well! Thanks!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.