Currently, Stencyl's raycast implementation is only suitable for detecting the distance between actors or single tiles. When attempting to raycast to complex terrain (2+ tiles that are connected to each other), raycasting becomes completely unreliable; sometimes it will travel through tiles, stop at a point between them, or any combination of the two. This is due to how Stencyl groups connected tiles together into a single continuous piece of geometry instead of individual tiles for performance purposes. It was suggested in this thread (http://community.stencyl.com/index.php/topic,61507.msg316725.html) to utilize the slope of the line to get the correct end location of the raycast, but I have been unable to replicate this. At this point it seems more like an issue with the engine itself that should not require this much extra work to calculate.
Essentially, a properly-functioning raycast should look something like this:
Essentially, a properly-functioning raycast should look something like this:
- Raycast line starts at point X1,Y1 and travels to X2, Y2.
- Creates a list of all objects it came into contact while traveling to that point.
- For actors and terrain, it returns the X,Y coordinates of the point on the actor/terrain it first made contact with.