• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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

F

Faexie

Guest
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 by a moderator:
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