godotengine / godotengine/godot-docs

An error in getting_started/first_2d_game/03.coding_the_player

Open
#8,698 1 comment 0 reactions 0 assignees View on GitHub
area:getting started bug discussion
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**This issues uses machine translation**
# Description
In the Choosing animations section, there is the following code
```gdscript
if velocity.x != 0:
$AnimatedSprite2D.animation = "walk"
$AnimatedSprite2D.flip_v = false
# See the note below about boolean assignment.
$AnimatedSprite2D.flip_h = velocity.x < 0
elif velocity.y != 0:
$AnimatedSprite2D.animation = "up"
$AnimatedSprite2D.flip_v = velocity.y > 0
```
I think it does not fulfill the intended function
If you want to make a move down to the left or right, it doesn't flip up and down,
I think it needs to be changed to the following code to achieve the desired effect.
```gdscript
if velocity.x != 0:
$AnimatedSprite2D.animation = "walk"
elif velocity.y != 0:
$AnimatedSprite2D.animation = "up"
if velocity.x != 0 or velocity.y != 0:
$AnimatedSprite2D.flip_h = velocity.x < 0
$AnimatedSprite2D.flip_v = velocity.y > 0
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.