I’m on the latest verison of godot and I’m making a two player game where the player play on the same keyboard similar the fireboy and watergirl. I got one characters sprite to flip around when they go left but the other one doesn’t even thought they have the same code. I used the sprite.flip_h = (direction == -1). Can someone help me figure out whats wrong?
Hi, you’ll have to post some code for us to help you out. Please post enough context relevant code that you believe will allow some rando on the internet to mentally reconstruct the issue.
Make sure to format the code with backticks like this:
```
func my_code():
print("hello world")
```
We’ll need the code of the character that’s not turning.
var direction := Input.get_axis("ui_left2", "ui_right2")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
print(direction)
if direction != 0:
$Sprite.flip_h = (direction == direction*(-1))
move_and_slide()
ui left 2 and right 2 are a and d respectively
direction == direction*(-1)
This will always be false (except for 0). It looks like this when you substitute direction with the value 1:
1. 1 == (1 * -1)
2. 1 == -1
A hint for flip_h: Try testing if the direction’s component of the given movement axis is greater than or less than 0.
Happy programming!
1 Like