Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 9BitStrider | |
Old Version | Published before Godot 3 was released. |
func _input(event):
if anim == "idle" and event.is_action_pressed("move_left"):
anim = "lilstep"
direction = -1
player.set_flip_h(false)
player.play(anim)
I’m working on a MegaMan styled engine. The above handles whenever the player presses left or right while on the ground. I want to move the sprite left or right a single pixel as part of this function but I’m unsure how to accomplish this. I tried using set_pos(), but that returned an error.
What error did set_pos()
return? What kind of node are you using for the player?
kidscancode | 2017-07-31 20:12
I’m using KinematicBody2D for the sprite with AnimatedSprite and CollisionShape2D as child nodes. The error that I’m getting back is: Invalid type in function ‘set_pos’ in base ‘KinematicBody2D (player.gd)’. Cannot convert argument 1 from float to Vector2.
I’m thinking that the syntax I’m using is just wrong. I was using
set_pos(pos.x - X_SPEED)
after
player.play(anim)
9BitStrider | 2017-07-31 20:16