First of all, i'd like to pologize for my bad english
Im doing the godot tutorial and i found a problem in the part where it teaches you how to flip your animation horizontally and vertically.
Whenever you try to make the player going both down and to some of the sides, the sprite flips vertically again, making it going down but pointing up at the same time.
Is there anyway i can fix that? Here is my code so far.
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
screen_size = get_viewport_rect().size
# Called when the node is added to the scene for the first time.
# Initialization here
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
export var speed = 400 #vel em pixel/segundo
var screen_size #tamanho da tela
var velocity = Vector2() # The player's movement vector.
velocity.x += 1
velocity.x -= 1
velocity.y += 1
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
position += velocity * delta
position.x = clamp(position.x, 0, screen_size.x)
position.y = clamp(position.y, 0, screen_size.y)
if velocity.x != 0:
$AnimatedSprite.animation = "right"
$AnimatedSprite.flip_v = false
#See the note below about boolean assignment
$AnimatedSprite.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite.animation = "up"
$AnimatedSprite.flip_v = velocity.y > 0