Game Maker Studio: How to Create a Light Follow?

Channel:
Subscribers:
268
Published on ● Video Link: https://www.youtube.com/watch?v=FALyZlTEVEQ



Duration: 16:16
166 views
0


Visit my MC GAMES site: https://mcolverdesigns.itch.io

Paypal Donate: http://bit.do/fkPAb

GMS File: https://bit.ly/30PLMav

Link: https://bit.ly/300Dtt3

oLighting:

Events:

Create

Actions:

globalvar light;
light = surface_create(view_wview,view_hview)

Events:

Step

Actions:

surface_set_target(light);
draw_set_color(c_white);
draw_rectangle(0,0,view_wview,view_hview,false)
surface_reset_target();

Events:

Draw

Actions:

draw_set_blend_mode(bm_subtract);
draw_surface(light,view_xview,view_yview);
draw_set_blend_mode(bm_normal);

sLight: Depth 10, this object will follow player along with light

Events:

Create

Actions:

target = obj_player_stop_r;
myspeed = 5;
length = 5;
place = 5; /////////////////////////make 0 for myspeed, length, place, if you don't want the circle object to hover around player.

Events:

Step

Actions:

x = obj_player_stop_r.x + lengthdir_x(length,place);
y = obj_player_stop_r.y + lengthdir_y(length,place);
place += myspeed;

Events:

End Step

Actions:

size = 150;////Change the size of light.
draw_set_blend_mode(bm_subtract);
surface_set_target(light);
draw_ellipse_color(x-size/2-view_xview,y-size/2-view_yview,x+size/2-view_xview,y+size/2-view_yview,c_white,c_black,false);
surface_reset_target();
draw_set_blend_mode(bm_normal)

////////Draw ellipse color: Change the first color, if you want the light to be a different color. Change the second color to anything but black, if you want the light to be sharp without a fade out.







Tags:
light
follow
game
maker
studio
move
room
in
teach
how
learn
player
draw
blend
mode
normal
target
surface
rectangle
view
hview
wview
set
subtract
false
global
globalvar
var
object
lighting
create
size
ellipse
color
length
direction
place
circle
bright
black
shadow
dark
dir
sub
image
flicker
flick
walk