New update - Ray Casting

Welcome back @“Mhx Ar”

http://flowlab.io/game/view/858376

Here’s a demo I’ve made using raycast. RPGs typically have at least two water tiles, one specifically placed beneath land to achieve some sort of visual dropoff effect, and the regular water tiles. With raycast you can use a single water block everywhere and have that dropoff effect applied once the game runs, a minor convenience, sure, but do this for many different blocks and you’ll save a lot of time with building maps.

Clever idea, @Wizardry

@Wizardry That’s a great idea. I used to use proximity for the same thing. Unfortunately, proximity can’t detect multiple directions, and flawed a few older tests. This ray cast can help you do what RPG Maker does and automatically border all edges when met with water, sand, road, etc.

Here’s some feedback on raycasting, it’s a little wonky with detecting hits or misses of specific blocks right now if there are other blocks in the way, it actually shouldn’t work at all with the grass blocks underlying everything but the results can vary sometimes with each run.

There’s a total of 4 block types in this picture, non-background grass blocks tiled over the entire area, and then layers of grey blocks and tree stumps, the stumps spawn foliage after running, everything has collison enabled.

On the left side, grey blocks are raycasting downward looking for another grey block, and if the raycast misses it displays a shadow animation.

The middle shows the grey blocks doing the same raycast, but also grass blocks raycasting upwards looking for a grey block, if they hit, a shadow animation is displayed for that grass block.

The right shows only the grass blocks raycasting.

With the grass blocks underneath everything in this picture it should be missing most of the raycasts, but you can see it somehow works most of the time, only with the vertically stacked grey blocks does it seem to have trouble.

This is now without the layer 1 grass blocks underneath everything, they were completely deleted, so only the grey blocks are raycasting now.

On the Left the trees obstruct the foliage consistently, and on the right with the trees removed to the left edge of the screen the raycasting works.

So by this point with all the grass blocks underneath deleted, it’s working as it should, the hits and misses are right.

Hey @Wizardry - thanks for the awesome detailed writeup! Can you post a link to that demo so I can check it out and maybe see where the discrepancy might be?

I had to remake it since I deleted most of the blocks narrowing down what accurately obstructs rays, and this time it seems to ‘work’ better detecting the target even with another block occupying the same position, it looks like if two objects are occupying the same space that the target has priority perhaps, more so than when I was testing yesterday at least: http://flowlab.io/game/view/860406