erayzesen
Member
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);
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
- 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.