-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add documentation on flipping for diagonal movement in 'First 2D Game" tutorial #11487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added instructions for handling diagonal movement animations and correcting animation flips based on player input. This fixes "moving sideways and down causes player to flip back on its feet" animation state
AThousandShips
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these changes are merged the demo project needs to be adjusted to match as well
| .. tabs:: | ||
| .. code-tab:: gdscript GDScript | ||
|
|
||
| if(velocity.x != 0 && velocity.y !=0): # If vertical and horizontal movement keys are pressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(velocity.x != 0 && velocity.y !=0): # If vertical and horizontal movement keys are pressed | |
| if velocity.x != 0 and velocity.y != 0: # If the vertical and horizontal movement keys are pressed. |
| $AnimatedSprite2D.flip_v = false | ||
| # See the note below about the following boolean assignment. | ||
| $AnimatedSprite2D.flip_h = velocity.x < 0 | ||
| elif velocity.y != 0 : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| elif velocity.y != 0 : | |
| elif velocity.y != 0: |
|
|
||
| .. code-tab:: csharp | ||
|
|
||
| if (velocity.X != 0 && velocity.Y != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (velocity.X != 0 && velocity.Y != 0) | |
| if (velocity.X != 0 && velocity.Y != 0) // If the vertical and horizontal movement keys are pressed. |
| Play the scene again and check that the animations are correct in each of the | ||
| directions. | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added instructions for handling diagonal movement animations and "correcting" animation flips based on player input. This fixes "moving sideways and down causes player to flip back on its feet" animation state.