Hello!
I have a ship that I'm reworking the movement on and have attached the relevant script below. My thrust variable acts like my speed and I've set it to 800. when I run, the velocity print statements for the 'left, right, up' directions max at 368 and my 'down' direction maxes at 775. The ship is a RigidBody2D and I'm sure I'm missing something simple about the physics. All my damp values and gravity scale is set to 0.
func _physics_process(delta):
mouse_pos = get_global_mouse_position()
var direction = mouse_pos - position
var mouse_angle = direction.angle()
var cur_vertical_velocity = get_linear_velocity().y
var cur_horizontal_velocity = get_linear_velocity().x
global_rotation = lerp_angle(global_rotation, mouse_angle, angular_speed)
if Input.is_action_pressed("move_right"):
set_linear_velocity(lerp(linear_velocity, Vector2(thrust, cur_vertical_velocity), 0.05))
print(linear_velocity)
if Input.is_action_pressed("move_left"):
set_linear_velocity(lerp(linear_velocity, Vector2(-thrust, cur_vertical_velocity), 0.05))
print(linear_velocity)
if Input.is_action_pressed("move_up"):
set_linear_velocity(lerp(linear_velocity, Vector2(cur_horizontal_velocity, -thrust), 0.05))
print(linear_velocity)
if Input.is_action_pressed("move_down"):
set_linear_velocity(lerp(linear_velocity, Vector2(cur_horizontal_velocity, thrust), 0.05))
print(linear_velocity)
else:
set_linear_velocity(lerp(linear_velocity, Vector2.ZERO, 0.06))
position = position.clamp(Vector2.ZERO + start_pos, ship_boundaries)
Thanks