Simple Raycast Script

erayzesen

Member
itch_cover.png
Hi all. I released a raycast code to use your any projects;

Note: It support Game Maker Studio v2.3 and new versions;

Check it out: (with online demo): https://erayzesen.itch.io/simple-raycast

The method;
GML:
var rc_data=raycast(_x,_y,_dir,_length,_per_pixel,_object,_tilemap_layer_name,_precise_mode);
It return a raycast data struct, you may get results with this way;
GML:
//To get the returned raycast type
rc_data.type // rc_type.nothing , rc_type.object , rc_type.tilemap
//To get the returned instance id or tilemap index
rc_data.index
//To get returned collision positions
rc_data.x
rc_data.y
FEATURES
  • It support a specific object, multiple objects, tilemap layers or all at the same time.
  • It may work with different collision shapes. ( Set to _precise_mode as true to do that.)
  • I added comments in the script if you want to learn how it works.
  • One script file and one method.
  • Flexible to use in all your projects.

I hope you like it. Cheers.
 
Top