G
G0vnah
Guest
(TL;DR version - I'm having trouble with the codes shown in the image. The game acts like the "view_w_half" and "view_h_half" variables don't exist on the step event page, and only uses the data they stand for if I put the data itself into that place).
------------------------------------------------------------------------------------------------------
Alright, I'm new to Game Maker Studio, but I absolutely love it. I've been following along with Shaun Spaulding's series, entitled "GameMaker Studio 2: Complete Platformer Tutorial."
Part 6 involves setting up an object to serve as a focus point for the camera.
I have the following script in the "create" event, where I place the variables upon the object's creation ('I've bolded the codes giving me trouble)
(just below are the event codes as text...)
[/INDENT]
-------------------------------------------------------------
Here's the problem:
Whenever I use the code above, the game seems to ignore the "view_w_half" and "view_h_half" variables entirely in the step event. It moves the camera so that the player is in the top left, always.
HOWEVER, if I manually type in that last line of code as shown below, it focuses in on the player just fine, putting them at the center:
Why is it seemingly ignoring those two variables from the "create" event, despite CLEARLY not ignoring any other variables?
------------------------------------------------------------------------------------------------------
Alright, I'm new to Game Maker Studio, but I absolutely love it. I've been following along with Shaun Spaulding's series, entitled "GameMaker Studio 2: Complete Platformer Tutorial."
Part 6 involves setting up an object to serve as a focus point for the camera.
I have the following script in the "create" event, where I place the variables upon the object's creation ('I've bolded the codes giving me trouble)
(just below are the event codes as text...)
Code:
cam = view_camera[0];
follow = oPlayer;
xTo = xstart;
yTo = ystart;
view_w_half = (camera_get_view_width(0)/2)
view_h_half = (camera_get_view_height(0)/2)
Code:
if (instance_exists(follow))
[INDENT]{
[INDENT]xTo = follow.x;
yTo = follow.y;[/INDENT]
};
x += (xTo - x)/25;
y += (yTo - y)/25;
camera_set_view_pos(cam,x - view_w_half, y - view_h_half);
Here's the problem:
Whenever I use the code above, the game seems to ignore the "view_w_half" and "view_h_half" variables entirely in the step event. It moves the camera so that the player is in the top left, always.
HOWEVER, if I manually type in that last line of code as shown below, it focuses in on the player just fine, putting them at the center:
Code:
camera_set_view_pos(cam,x - (camera_get_view_width(0)/2), y - (camera_get_view_height(0)/2);