Dropping Through One Way Platforms

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

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.

:bust_in_silhouette: Reply From: avencherus

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
:bust_in_silhouette: Reply From: Jonathan Picques

If you are using a KinematicBody2D for your player:

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

Did the trick for me

This worked for me too, super easy.

madcapacity | 2018-06-14 20:44

Me as well! Thanks!

mrhollow | 2021-01-25 01:13