Hello i am new to game development and i am trying to make my first game with top-down perspective
and now i'm trying to make the node movement effected by its current rotation, i already tried to rotated the movement directly
with its rotation but it doesnt end well, and i end up with code similar to this:
velocity = Vector2()#this line somehow make thing work
target_speed = 0
if Input.is_action_pressed('ui_up'):
target_speed = speed
sailing = true
if Input.is_action_pressed('ui_down'):
target_speed = -speed/2
sailing = true
velocity.x = target_speed
velocity = velocity.rotated(rotation)
its work but now i want to make the node to accelerate, and make the code like this:
target_speed = 0
if Input.is_action_pressed('ui_up'):
target_speed = speed
sailing = true
if Input.is_action_pressed('ui_down'):
target_speed = -speed/2
sailing = true
velocity.x = lerp(velocity.x,target_speed,0.1)
velocity = velocity.rotated(rotation)
but end up with weird movement,it does accelerating though, and i think the "velocity = Vector2()" code is the one make thing work
is there any way to make the node accelerating while effected by the rotation?, i have searching through internet but still doesnt find the solution.