var dir,dist,targetX,targetY; dir = point_direction(objPlayer.x,objPlayer.y,mouse_x,mouse_y); dist = point_distance(objPlayer.x,objPlayer.y,mouse_x,mouse_y); targetX = objPlayer.x + lengthdir_x(dist/2,dir); targetY = objPlayer.y + lengthdir_y(dist/2,dir); view_xview[viewNum] = targetX - view_wview[viewNum/2]; view_hview[viewNum] = targetY - view_hview[viewNum/2];
This should do the trick. It's untested, but pretty straightforward, let me know if it doesn't work. Obviously replace the object names with your own. Mouse coordinates can be easily substituted with an object's coordinates if you don't use the regular mouse. This should go in the step event of a main controller object.
Let me know if there's any issues.