![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | bgegg |
i try this tutorial.
i can not move character when use stop() function for sprite animation.
https://youtu.be/XA1TPg6yiiA?list=PLsk-HSGFjnaFutTDzgik2KMRl6W1JxFgD&t=600
where is bad?
extends Area2D
export (int) var speed
var velocity = Vector2()
var screesize
func _ready():
screesize = get_viewport_rect().size
print(screesize)
func _process(delta):
velocity = Vector2()
if Input.is_action_pressed("ui_right"):
velocity.x +=1
if Input.is_action_pressed("ui_left"):
velocity.x -=1
if Input.is_action_pressed("ui_up"):
velocity.y -=1
if Input.is_action_pressed("ui_down"):
velocity.y += 1
if velocity.length() > 0:
$AnimatedSprite.play()
velocity = velocity.normalized() * speed
else:
$AnimatedSprite.stop()
position += velocity * delta
position.x = clamp(position.x,0,screesize.x)
position.y = clamp(position.y,0,screesize.y)
If i use only play() function, it works without any problems.
i can not move add this code.
else:
$AnimatedSprite.stop()
There is no error message
please help
Thank you for this question. Just had the same problem. Had a laugh after the solution. Here I was pulling out my hair. Anyways I had a problem with the shooter. The bullets were not shooting. Did you find a way around it.
kwadjoOnline | 2019-05-27 16:04