Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Alocktrix |
Hello I’m having trouble on using my [var is_facing], in an [if] statement. The [func facing] works but for some reason when I use it as a check for my [func dash], the [if] statement doesn’t go through. And yes [func dash], and [func facing], is in [func _physics_process].
My apologies if my english/terminology is off.
var is_facing = Vector2.ZERO
func facing():
if Input.is_action_pressed("Left"):
var is_facing = Vector2.LEFT
# print(is_facing)
elif Input.is_action_pressed("Right"):
var is_facing = Vector2.RIGHT
# print(is_facing)
func dash():
if Input.is_action_just_pressed("Dash") and is_facing == Vector2.LEFT:
velocity.x = velocity.x - dash_lenth
print("dash left")
elif Input.is_action_just_pressed("Dash") and is_facing == Vector2.RIGHT:
velocity.x = velocity.x + dash_lenth
print("dash right")