Created
April 4, 2018 17:16
-
-
Save jedStevens/1cefbe8487c3022154bd7116f183401f to your computer and use it in GitHub Desktop.
Makes a PhysicsBody2D fall through a platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Area2D | |
const DOULBE_TAP_MAX_TIME = 0.25 | |
const MAX_NAV_DISABLE = 0.4 | |
var double_tap_timer = 0 | |
signal nav_enable | |
func _ready(): | |
set_physics_process(true) | |
func _physics_process(delta): | |
if get_overlapping_bodies().size() == 0: | |
emit_signal("nav_enable") | |
var double_tap_down = false | |
if double_tap_timer > 0: | |
double_tap_timer -= delta | |
if Input.is_action_just_pressed("ui_down"): | |
double_tap_down = true | |
if double_tap_timer < 0: | |
double_tap_timer = 0 | |
else: | |
if Input.is_action_just_pressed("ui_down"): | |
double_tap_timer = DOULBE_TAP_MAX_TIME | |
if double_tap_down: | |
for body in get_overlapping_bodies(): | |
disable_until_separated(body) | |
func disable_until_separated(collider): | |
get_parent().add_collision_exception_with(collider) | |
yield(self, "nav_enable") | |
get_parent().remove_collision_exception_with(collider) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment