M
MatthewL019
Guest
Hello. I'm currently developing a top-down game that involves rotating the player sprite to face the mouse's position.
I am aware of the common trick:
However this looks very choppy to me, and I would like to implement a smoothing feature.
I tried using lerp for the first time, and here are my results (gifs):
https://gyazo.com/8767afff21180549aef3a67dcb92d5e3
https://gyazo.com/e38eb1309835a7893f702216058868be
Here is the code:
It seems to work perfectly, actually, apart from one small thing... When dir goes from 0 to 360 (at the right side) it totally messes up the lerp and spins the character around...
Anyone have a solution? Thanks!
I am aware of the common trick:
Code:
image_angle = point_direction(x,y,mouse_x,mouse_y);
I tried using lerp for the first time, and here are my results (gifs):
https://gyazo.com/8767afff21180549aef3a67dcb92d5e3
https://gyazo.com/e38eb1309835a7893f702216058868be
Here is the code:
Code:
// Direction
dir = point_direction(x,y,mouse_x,mouse_y);
image_angle = lerp(image_angle, dir, 0.1);
Anyone have a solution? Thanks!