- Edited
I want to be able to thrust in multiple directions but if I use IF statements instead of ELIF statements, only the last statement will work at all, i.e. only "lateral_right" will work. Why doesn't it work like "rot" does where I can use IF statements and they both work?
func get_input():
rot = 0
if Input.is_action_pressed("player_left"):
rot -= rot_speed
if Input.is_action_pressed("player_right"):
rot += rot_speed
if Input.is_action_pressed("player_thrust"):
acc = Vector2(thrust, 0).rotated(rotation - PI / 2)
elif Input.is_action_pressed("lateral_left"):
acc = Vector2(thrust, 0).rotated(rotation + PI)
elif Input.is_action_pressed("lateral_right"):
acc = Vector2(thrust, 0).rotated(rotation)
else:
acc = Vector2(0, 0)
func _process(delta):
# detect input
get_input()
# calculations
acc -= vel * friction
vel += acc * delta
#vel += (acc + accl) * delta
rotation += rot_speed * rot * delta
# stay on screen
if position.x >= screensize.x:
position.x = 0
if position.x < 0:
position.x = screensize.x
if position.y >= screensize.y:
position.y = 0
if position.y < 0:
position.y = screensize.y
position += vel * delta