• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Camera not following outside room

R

Roughskirt

Guest
Hi,

The camera only follows my player inside the room but when I move to the edge of the room the camera just doesnt follow.

This is the code im using to create the camera:
Code:
camera = camera_create_view(0, 0, 1024, 768, 0, obj_player, -1, -1, 512, 384);
view_camera[0] = camera;
I hope someone can help me to fix this since its very annoying.

~ Roughskirt
 

Smiechu

Member
Hi,

The camera only follows my player inside the room but when I move to the edge of the room the camera just doesnt follow.

This is the code im using to create the camera:
Code:
camera = camera_create_view(0, 0, 1024, 768, 0, obj_player, -1, -1, 512, 384);
view_camera[0] = camera;
I hope someone can help me to fix this since its very annoying.

~ Roughskirt
From what I know this is how it works... You can't look outside the room...
You need to make the room bigger (half of the screen hight/lenght), and program an inner border for the player...
 
R

Roughskirt

Guest
Well thats the problem I dont know how big my room is gonna be. The terrain is randomly generated. So it creates a new chunk when Im close to the edge of the room.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You need ti use the camera_set_pos function to set the camera position manually rather than use the automatic object following. Object following clamped to the room bouds, while if you set the position yourself it's not. So, something like this in the object that you want the camera to follow:

Code:
var _vw = camera_get_view_width(view_camera[0]) / 2;
var _vh = camera_get_view_height(view_camera[0]) / 2;
camera_set_view_pos(view_camera[0], x - _vw, y - _vh);
 
Top