It worked! Thank you!!
I made a global variable called GlobalDir and gave it a variable called direction, set that equal to 1.
Then, in the Player script, I added an If statement that checks if xinput is < 0. If it is, the GlobalDir's direction variable is updated to -1. Then the same for xinput > 0 and 1.
Next I created a function called SpawnCheck( ). It uses an If statement to see if GlobalDir's direction is less than zero. If it is, then it sets the boolean flip_h from the sprite node to true.
Last, I added added the SpawnCheck( ) function to the physic process, so that it checks for it every frame.
Here is the code:
var direction = 1
Player's Physic Process:
var x_input = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
if x_input != 0:
motion.x += x_input * acceleration * delta
motion.x = clamp(motion.x, -max_speed, max_speed)
sprite.flip_h = x_input < 0
if x_input < 0:
GlobalDir.direction = -1
if x_input > 0:
GlobalDir.direction = 1
I did have another question if you are game for it. Do you know why the
"sprite.fliph = xinput < 0"
line works (under If xinput != 0)?
Does the negative xinput value equate to a "false" in boolean terms?