Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | vitalezzz |
Hello
I’m new at godot engine. I’m trying to make a space shooter game and I’ve encountered a little problem.
I am moving my ship with that code:
if button_up.is_pressed():`
velocity += Vector2(acceleration, 0).rotated(rotation + deg2rad(-90))
move_and_slide(velocity)
I made it so ship moves to where it’s pointing and it works pretty fine. However when I’m moving to degrees between 1 and 89, 91 and 179 etc., both velocity.x and velocity.y keep rising until it reaches max_speed and that results in my ship moving directly 45, 135, 225 or 315 degrees and not where it’s pointing.
I want to make it so when for example velocity.x reaches max_speed, vector.y gets limited to its current value. Is it possible?
Thank you in advance and excuse me for my english