• 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.

HTML5 GMS 2 HTML 5 Export Camera Problem

Pedro Y

Member
Hi guys! As you can see in the title of this thread, I am currently meeting a small problem with the HTML 5 export.

I am using Mac OS, and the mac export version of the game works finely, camera following the player. However, I want to put my game on itch.io, so I HTML5 exported the game as a zip, and uploaded it to itch.io. This is when the weird thing happens: all other parts of the game works correctly, but the camera doesn't follow the player around.

In case you are wondering, I am using an o_camera object in my game instead of using the given "player follow" option in the room inspector.

I would really appreciate any sort of answers! Is this a bug or is there something that I should do? Thank you very much!
 

Pedro Y

Member
Does this only happen in HTML5? Or works normal on Windows?
What code did you use on camera?
yes, this does only happen in HTML5, but since I do not have a pc I do not know if it is only on mac.
and for my camera code, here it is:
create event:
GML:
/// @description set up camera
cam = view_camera[0];
follow = o_player;
follow1 = o_player1;
follow2 = o_player2

scroll_x_margin = 0.5;
scroll_y_margin = 0.5;

view_w_margin = camera_get_view_width(cam) * scroll_x_margin;
view_h_margin = camera_get_view_height(cam) * scroll_y_margin;
x_to = xstart;
y_to = ystart;

shake_length = 0;
shake_magnitude = 0;
shake_remain = 0;
buff = 32;
step event:
GML:
if (room = r_1)
{
scroll_x_margin = 0.5;
scroll_y_margin = 0.48;
}


if (room = r_talk) || (room = r_talk1) || (room = r_talk2) || (room = r_death_talk) || (room = r_death_talk1) || (room = r_death_talk2)
{
scroll_x_margin = 0.5;
scroll_y_margin = 0.48;
}

if (room = r_explanation) || (room = r_explanation1) || (room = r_explanation2)
{
buff = 0;
scroll_x_margin = 0.5;
scroll_y_margin = 0.5;
}
else
{
buff = 32;
}


/// @description update camera

view_w_margin = camera_get_view_width(cam) * scroll_x_margin;
view_h_margin = camera_get_view_height(cam) * scroll_y_margin;
//update destination

if (instance_exists(follow))
{
    x_to = follow.x;
    y_to = follow.y;
}
if (instance_exists(follow1))
{
    x_to = follow1.x;
    y_to = follow1.y;
}
if (instance_exists(follow2))
{
    x_to = follow2.x;
    y_to = follow2.y;
}

//update object position

x = x + (x_to - x) / 25;
y = y + (y_to - y) / 25;

x = clamp (x,view_w_margin+buff,room_width-view_w_margin-buff);
y = clamp (y,view_h_margin+buff,room_height-view_h_margin-buff);

//screen shake
x = x + random_range(-shake_remain,shake_remain);
y = y + random_range(-shake_remain,shake_remain);
shake_remain = max(0,shake_remain-((1/shake_length)*shake_magnitude));

//update camera view

camera_set_view_pos(cam,x-view_w_margin,y-view_h_margin);

if (layer_exists("Mountains"))
{
    layer_x("Mountains",x/3);
}
if (layer_exists("Trees"))
{
    layer_x("Trees",0);
}
if (layer_exists("Background"))
{
    layer_x("Background",x +512);
}
room start event:
if (room == r_2) instance_destroy();
 
Top