Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | OpSyKi |
I want to make a platformer that disable the usage of a platform by pressing a keyboard/controller button, pressing the button again enables the platform. The code I wrote made the collison turn off and immediately on again.
Take a look:
extends StaticBody2D
var red_c = true
func _process(delta):
if Input.is_action_just_pressed("Action"):
if red_c == true:
$CollisionShape2D.set_disabled(true)
$AnimatedSprite.play("blue")
red_c = false
if Input.is_action_just_pressed("Action"):
if red_c == false:
$CollisionShape2D.set_disabled(false)
$AnimatedSprite.play("red")
red_c = true