||Topic was automatically imported from the old Question2Answer platform.
Here is my code:
if Input.is_action_pressed("ui_right") and Input.is_action_pressed("ui_left"):
motion.x = 0
motion.x = SPEED * delta
motion.x = -SPEED * delta
else: motion.x = lerp (motion.x,0,0.75)
I have also tried
Are you trying to flip horizontally or vertically?
spoicat | 2021-05-23 02:07
horizontally, I am making a platformer
antoniodev | 2021-05-23 12:37
You can try
self.rotation_degrees = 180
to flip the entire Node (and its childrens)
This makes the player upside down
antoniodev | 2021-05-22 20:42
Oops, yes you are right. Dont know then
Pomelo | 2021-05-22 23:49
Maybe I’m late.
To flip any node horizontally, set the
scale property to
Example: I want to flip my sprite and collisionShape2D horizontally:
var flip = Vector2(-1,1)
$<sprite_name>.scale = flip
$<collisionShape2D_name>.scale = flip
If you use a scale for scaling objects then you’d have to set the value relatively I guess
Altought this won’t work for Node2D, for that you’d have to instance that Node2D as a child inside another Node2D using it as an anchor, then flip the parent (anchor)
Image (somewhy it wont appear here): https://drive.google.com/uc?export=view&id=1QmPG2g99J2CvkrdVr5pCOdiciRnHHl8J
SIMPLE AND QUICKER SOLUTION: If you want to stay outta all those trouble you can just flip the whole player node instead.