How to make the camera rotate on its center instead of the top left corner?

Faexie

Member
Update: The camera actually is rotating with the player, it turns out. It's just that it's rotating around its origin at the top left corner, so it doesn't look like the player is pointing up at all times like I wanted it to. Is there a way to change the camera's origin so it's centered, or something else that would give the same effect?


I have an issue with my camera. I'm trying to make it rotate along with the player, but it doesn't seem to work... It does adjust its angle at creation, but if I rotate the player it doesn't update.

Here's the code in the end step event:
if(instance_exists(Oplayer))
{
var _x = Oplayer.x - view_width/2
var _y = Oplayer.y - view_height/2
camera_set_view_pos(view,_x,_y)
camera_set_view_angle(view,Oplayer.angle))
}
 
Last edited:
I don't know much about camera rotation. But from the sounds of it, you could allow it to rotate from the top left, and simply change the position in relation to the rotation. Like this:
GML:
//just psudocode
dis = point_distance(player.x,player.y,camaraLeft,camaraTop)
dir = point_direction(player.x,player.y,camaraLeft,camaraTop)

camx = player.x + lengthdir_x(dis,dir+camaraRotation)
camy = player.y + lengthdir_y(dis,dir+camaraRotation)
 
Top