Rivo
7014
I currently have code that makes the view follow my player.
That works perfectly fine. But, I'm also trying to make the camera tween a bit toward the mouse too, so the player can see a bit more of the screen in the direction he/she points the mouse. (But not too much, so the player is still in screen)
Here is my attempt.
Biggest problem is, I'm having trouble picturing how it works. I understand that the code moves toward a point and slows down whilst moving toward it. But I don't really understand much more than that. ^ I took the player movement code above from somewhere else and tried to make sense of it but, i'm not quite understanding. So, for me to attempt to create the effect i want with the mouse, I would need to understand better the lerp fucntion and how people use tweening in gamemaker, since all I can find online is crappy videos from people who barely explain it.
So, if anyone could help me with this code and/or help my understand better, that would be great! Thank you.
Code:
// View smoothly follows player
view_xview[0] = lerp(view_xview[0], x-view_wview[0]/2, 0.1);
view_yview[0] = lerp(view_yview[0], y-view_hview[0]/2, 0.1);
Here is my attempt.
Code:
// mouse effect
target_x = point_direction(x, y, mouse_x/2, mouse_y/2);
target_y = point_direction(x, y, mouse_x/2, mouse_y/2);
view_xview[0] = lerp(view_xview[0], mouse_x-target_x, 0.1);
view_yview[0] = lerp(view_yview[0], mouse_y-target_y, 0.1);
So, if anyone could help me with this code and/or help my understand better, that would be great! Thank you.