Open Polyolty opened 9 months ago
For GMS, the current system for raycasts is well-understood boilerplate code scr_rangeFinderExact(). You can find this readily online and it's licensed so that you or anybody else can use it.
It uses a brute-force recursive algorithm to find the nearest intersection between a line segment and an Instance or Instance type or array of instances, using GMS's line_collision() function.
This should've been built into GMS years ago and made fast with C++ under the hood, and I've already asked YYG to maybe get around to allowing raycasts in Physics World.
Is your feature request related to a problem?
Currently directional collision detection and entity sensing is not as straightforward as it could be. While these can be implemented in the current form of the code, there are better alternatives.
Describe the solution you'd like
Raycasts. We can set a ray to originate from the origin point, and travel indefinitely or along a set distance. We can set it with angle ranging from 0 degrees to 359, or with built in up, down, left, right functions. These can be used in a wide range of applications, such as detecting whether an entity has made contact with the ray, or using it for enemies that patrol and need wall detection. We could set mutilple rays to originate to even determine how far along the collision path the opposing force is (ie, set 8 raycasts in front of a door. If 4 or more have been broken allow the door and player to interact)
Describe alternatives you've considered
No response
Additional context
No response