GameMaker Camera not moving

DesArts

Member
I'm new to GMS2 such so that I'll come across simple issues unfortunately.
My camera position is perpetually at (-1, -1) despite being set to the correct position (I know it's been set correctly). I'm obviously doing something very wrong somewhere.

Create event of persistent screen control object
Code:
global.Camera = camera_create_view(0, 0, Width, Height, 0, -4, 0, 0 ,0, 0);
view_set_camera(0, global.Camera);
Room start event of same persistent screen control object
Code:
view_enabled = 1;
view_visible[0] = 1;
view_set_camera(0, global.Camera);
End step of a camera control object
Code:
camera_set_view_pos(global.Camera, ViewX, ViewY);
ViewX and ViewY are 100% correct.


I'm sure it's possibly obvious to those more versed in GMS2 logic. Am I missing something or doing something incorrectly? Is there any known pitfall which can unintentionally move the camera? This is a project I'm migrating to the newer GM version.

I should mention I've checked for other code moving the camera and no, the line I've given is the only time the function is called.

Perhaps I'm doing it all wrong.
 

Bingdom

Googledom
I don't use gms2, but I think I may know the problem.

In gms1.4's room editor, there was a way for you to set the view to follow a object. Have you accidently did that to one of the views and made it follow the screen control object (which stays still, I'm assuming)?
 

DesArts

Member
Yeah I do think the code I've shown is pretty much correct and no - sadly it's not that simple I've just checked and it's not trying to follow anything. The object is definitely in the room (if it wasn't there'd be an error).

That means there must be some other way that the view could be moved?

-

Okay so if I create a new camera every room that fixes things. I thought you could use one camera throughout different rooms? I was setting the view to the camera each time so I don't know what the issue was.
 
Last edited:

Bingdom

Googledom
Ok, by looking at the manual, I've noticed an issue with your initailization.

In the sixth argument, it asks for an object to follow.
upload_2017-6-20_19-5-3.png

You have put "-4", which means noone.
upload_2017-6-20_19-5-56.png

You have probably told the camera system to follow nothing. By setting it to "-1", you may be telling the camera to not try to follow anything at all.

I think telling a camera (or view in gms1.4) to try to follow an object (whether it exists or not), may overwrite manual input coordinates. I've mostly used view_x/yview so I haven't experimented enough to test this theory. ;)

That would be my second guess.

Otherwise, it could be because view_enabled is not an array?
 
Last edited:

DesArts

Member
I actually just solved it, apparently it needs to have it's matrices reset for each room. I was thinking that was only needed when you wanted to change them. Thanks for the help!

Seems to only work if I destroy the camera first.

I will mark as solved soon - however anyone have any reason why this might be the case?
Currently the only method working 100% for me is using camera_create_view for a new camera each room.
 
Last edited:
Top