Player Lighting Running Off By Itself

Hello! So I followed a couple tutorials on how to make a sort of torch effect for my player, and the lighting looks cool, but it seems that as soon as I start moving my player, the torchlight moves faster and so it seems to run off by itself and is not attached to where my player is. How can I make sure that it's moving at the same pace as the player?

I'm confused because I'm simply drawing an ellipse on a surface at the player's end step at positions:
x - (size of ellipse: 1000) * 2, y - size * 2, x + size, y + size

If I'm not mistaken, shouldn't it simply draw a large circle around my player, but always be locked in based on where the x and y of the player is? The light does stop moving when I stop, but the light moves way faster. Why?

Here's the actual code involved:

Create:
Code:
globalvar light;
light = surface_create(2500, 1500);
depth = - 99;
Step:
Code:
if room != rm_title {
    surface_set_target(light);
    draw_set_color(c_ltgray);
    draw_rectangle(0, 0, 2500, 1500, false);
    surface_reset_target();
}
Draw:
Code:
if room != rm_title {
    gpu_set_blendmode(bm_subtract);
    draw_surface(light, Camera.x - 1100, Camera.y - 600);
    gpu_set_blendmode(bm_normal);
}

Code:
var size = 1000;
var x1 = x - size * 2;
var y1 = y - size * 2;
var x2 = x + size;
var y2 = y + size;
gpu_set_blendmode(bm_subtract);
surface_set_target(light);
draw_ellipse_color(x1, y1, x2, y2, c_white, c_black, false);
surface_reset_target();
gpu_set_blendmode(bm_normal);

Anyways, thanks for any help!
 

TheBroman90

Member
In Game Maker 1 that would be
Code:
draw_ellipse_color(x1-view_xview, y1-view_yview, x2-view_xview, y2-view_yview, c_white, c_black, false);
 
@TheBroman90 unfortunately I'm using studio 2, so view_xview doesn't work. Instead I'm using cameras.

Tried this but it didn't work:

Code:
var size = 1000;
var x1 = x - size * 2 - camera_get_view_x(view_camera[0]);
var y1 = y - size * 2 - camera_get_view_y(view_camera[0]);
var x2 = x + size - camera_get_view_x(view_camera[0]);
var y2 = y + size - camera_get_view_y(view_camera[0]);
gpu_set_blendmode(bm_subtract);
surface_set_target(light);
draw_ellipse_color(x1, y1, x2, y2, c_white, c_black, false);
surface_reset_target();
gpu_set_blendmode(bm_normal);
Anything I did wrong?
 

TheBroman90

Member
What if you try this

Code:
var x1 = (x - size * 2) - camera_get_view_x(view_camera[0]);
var y1 = (y - size * 2) - camera_get_view_y(view_camera[0]);
var x2 =(x + size) - camera_get_view_x(view_camera[0]);
var y2 = (y + size) - camera_get_view_y(view_camera[0]);
 
@TheBroman90 so those values are there because my actual view height and width didn't work, 1920x1080, simply because I have a screen shake effect and for whatever reason, the shadow wouldn't shake with the camera. So instead I just drew it a little bigger

And the camera.x and y are essentially the 0,0 of my view if I'm not mistaken
 
Top