Direction doesn't properly change #278
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
I get the confusion, it got me for a while too. Bottom line is that the player's direction variable doesn't control the orientation of the player's sprite object. To do that in current 4.3, use <player_object>.sprite.flip_h = <false for left, true for right> player-refactor branch resolves this ambiguity by instead asking you to use the PlayerChar.set_direction(new_direction: PlayerChar.DIRECTIONS) function. That looks like this... And instead of as you have above, you'd use to make it face to the right and to make it face to the left. Note that while this currently isn't the case, the player's sprite variable and the player's direction variable will be locked behind accessors and mutators (like this function) in the future. |
Beta Was this translation helpful? Give feedback.
-
|
In the example code you provided, that would be the 'parent' variable. This is a little more obvious in PlayerState.gd in the player-refactor branch since I've been explicitly putting types on everything that I take an interest in. ## A PlayerCharState is a state that a PlayerChar can be in. A player can only
## be in one active PlayerCharState at a time and the state will invoke its
## process and physics process actions for every frame that state is active for
## the PlayerChar.
class_name PlayerState extends Node
@onready var parent: PlayerChar
## Does this state make the player invulnerable (to things like crushing or falling)
@export var _invulnerability = false
## Does this state generally leave hands free? Can you grab things in this state?
@export var _hands_free = true
# Stores supplements that get applied when this state is processed
var process_supplements = [] |
Beta Was this translation helpful? Give feedback.

I get the confusion, it got me for a while too. Bottom line is that the player's direction variable doesn't control the orientation of the player's sprite object. To do that in current 4.3, use <player_object>.sprite.flip_h = <false for left, true for right>
player-refactor branch resolves this ambiguity by instead asking you to use the PlayerChar.set_direction(new_direction: PlayerChar.DIRECTIONS) function. That looks like this...
A…