Asset - Scripts Collision Arc with L.o.S.

Nocturne

Friendly Tyrant
Forum Staff
Admin

Ever wanted to check to see if there is a collision within an arc of a circle or create a "cone of vision" for AI? Well, you can, and easily, with this asset! You do not even need to change anything, just add the scripts and call them like any other GML function!

This asset contains two sets of scripts:

  • Set One: This set contains the basic collision_arc script that functions exactly the same as the GML collision_ functions, as well as an additional collision_arc_draw script that permits you to draw the defined collision arc to the screen in multiple different ways.
Screenshot1.png
  • Set Two: This set contains the advanced collision_arc_instance scripts. These scripts are designed to help create an AI "cone of vision", and as such require you to call a set up script in the Create Event of the instance to use them, before calling the general collision_arc_instance script in the Step Event. The idea here is that the scripts will not only check for an instance within the collision arc, but they will also check to see if the instance can be "seen" or not by checking to see if there is a line of sight between the calling instance and the "seen" instance. This line of sight will be checked against the "wall" object of your choice, or even a tile layer that you give (or both, so you can use the tile layer for "walls" and then use instances for additional obstacles). These instance scripts also have draw scripts, getter scripts and setter scripts, making them incredibly easy to use.
Screenshot_2.png
Both sets of scripts have a "fast" option which can be enabled or disabled to use better precision or not, and all scripts have been highly optimised and contain extensive comments. There is an additional collision_arc_instance_draw_batch script too, which permits you to batch all arc draw calls and so maintain texture swap overhead as low as possible. All of this is illustrated in the Demo that comes with the asset.

 

rIKmAN

Member
This line of sight will be checked against the "wall" object of your choice, or even a tile layer that you give (or both, so you can use the tile layer for "walls" and then use instances for additional obstacles). These instance scripts also have draw scripts, getter scripts and setter scripts, making them incredibly easy to use.
Is this asset compatible with GMS2?

edit:
I've just noticed the GMS2 tag on this thread so I assume that it is a GMS2 asset, but if you could still confirm whether it's a "made for GMS2" asset or a "1.4 imported with compatibility scripts" asset, that'd be appreciated.

Also, I don't predict any - but as you're the author of both I may as well ask: would there be any any issues using this with Aura 2.0?​
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
The package is 100% GMS2 and has no compatibility scripts with it. It should also be perfectly compatible with my Aura package in terms of processing the collisions, although the debug drawing that comes with the package may cause with colour and blending (but really the draw functions are included for debugging and not really as something to use in a game... although you could).
 

rIKmAN

Member
The package is 100% GMS2 and has no compatibility scripts with it. It should also be perfectly compatible with my Aura package in terms of processing the collisions, although the debug drawing that comes with the package may cause with colour and blending (but really the draw functions are included for debugging and not really as something to use in a game... although you could).
Cheers mate - purchased!
 

rIKmAN

Member
How would one go about expanding this to make it so that the cones are cut off when hitting a wall?
I would also be interested in hearing your thoughts on this @Nocturne.
I'm guessing it would use a similar method to how you calculate the shadowed areas in Aura?

Any possibility it may be added?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
:)

I hadn't actually thought about making the visual part of it work like that, tbh. The asset is for collision detection, and the visual part was added as a helper tool. It would make a nice addition though, so I'll look at updating it in the near future (this weekend at the earliest). Cheers!
 

rIKmAN

Member
:)

I hadn't actually thought about making the visual part of it work like that, tbh. The asset is for collision detection, and the visual part was added as a helper tool. It would make a nice addition though, so I'll look at updating it in the near future (this weekend at the earliest). Cheers!
Oh nice - that's great news!
I've watched this thread and look forward to the update, cheers mate! :)
 
Top