A
AUGE
Guest
I just wonder, how do I make camera stay on an object and only move when object moves. When I tried to do so, the camera would accelerate by the speed of the distance from mouse to the middle of the view. Any suggestions, please.
Ok, this works, but I need some more help here. How do I make the crosshair only move when mouse moves and later after it's goes back to normal (where crosshair tracks mouse) how do I make mouse in the middle and not somewhere moved in the corner while aiming with your code?I would just use something like this:
view_xview[0] = lerp(view_xview[0],obj_player.x-(view_wview[0]*0.5),0.05)
view_yview[0] = lerp(view_yview[0],obj_player.y-(view_hview[0]*0.5),0.05)
just change obj_player to your cross_hair object or what ever object you want to follow smoothly and change 0.05 to be faster or slower.
This would make the camera ccelerate the each time I move mouse. I want camera to move a bit after I move mouse, and then reset camera move speed to 0 and mouse to current position of the crosshair.Can you not just say:
obj_cosshair.x = mouse_x
obj_cosshair.y = mouse_y
I'm going to need a little more information on what your trying to do exactly?
if mouse_check_button(mb_right)
{
global.aiming=true;
}
else
{
global.aiming=false;
}
if global.aiming==false
{
x = mouse_x;
y = mouse_y;
old_x=mouse_x;
old_y=mouse_y;
}
else
{
//window_mouse_set(window_get_width() / 2, window_get_height() / 2);
x = mouse_x;
y = mouse_y;
view_xview[0] = lerp(view_xview[0],x-(view_wview[0]*0.5),0.1)
view_yview[0] = lerp(view_yview[0],y-(view_hview[0]*0.5),0.1)
}
x += mouse_x - old_x;
y += mouse_y - old_y;
old_x=mouse_x;
old_y=mouse_y;
view_xview[0] = x - (view_wview/2);
view_yview[0] = y - (view_hview/2);
window_mouse_set((window_get_width() / 2), (window_get_height() / 2));