S
Shadowblitz16
Guest
can someone help me I'm looking for a way to slowly move a value towards another value at a set speed
I would prefer to use something that uses one line of code if that is possible
I do not want to use lerp because it has problems reaching the target value(please do not argue with me on this)
something along the lines of move_towards_value(value, target)
Edit: here is my current code
I am aiming to make it slowly rotate the ship towards the input but when it is released it slowly turns back to 0 or frame 1
I would prefer to use something that uses one line of code if that is possible
I do not want to use lerp because it has problems reaching the target value(please do not argue with me on this)
something along the lines of move_towards_value(value, target)
Edit: here is my current code
Code:
///Update vars
//get axis input
var h = keyboard_check(vk_right) - keyboard_check(vk_left);
var v = keyboard_check(vk_down) - keyboard_check(vk_up);
//move ship
x += h * hsp;
y += v * vsp;
//animate ship
tilt = clamp((tilt + h*0.2), -1, 1)
image_index = tilt+1;