Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

New update - Ray Casting

edited April 2018 in Announcements
So I just deployed an update with a new type of of behavior block: RayCast. This is something that has been needed for a long time.

Ray Cast will send out and invisible ray from your object, and outputs either a hit or miss depending on whether it strikes another object. This allows an object to check the space around it. Among other things, it can be used to:

* Easily check if the object is on the ground, to prevent double jumping
* Check the space in front of an NPC, so that they don't walk off a cliff
* Checking line-of-sight for enemies
* Anything that requires checking the objects around you, like collision checking for grid-based collision detection

Documentation was added to the behavior handbook, and an example with an NPC cliff check, and double-jump prevention is here:

Let me know if you have any issues or questions!


  • Give me an example on how to use this, Ray cast...

    For some reason it makes me think of the original “Doom” because of the raycasting tech they used back then
  • Doesn’t this also mean pathfinding is technically possible now?!
  • @CrimsonBlackGames - I linked an example in the comment :)

    It shows how to use a RayCast to check for edges, and how to use it to prevent double jumps.

    While this is technically the same principle that Doom & Wolfenstein used, this is not really a useful method of rendering. I suppose you could use this for pathfinding though - I'll try to work up an example for that as well.
  • edited March 2018
    If flowlab had a limited 3D function for that... SB4 would exist.

    Now that I think about it, more cleverly made pac-man clones would exist on flowlab.
  • Oh nice now I can fix my games.

    When do rounded rectangle colliders come so I can fix cube's adventure.
  • This is really nice. I can do a lot of things with this.

    It would be cool if we could see it on ctrl+D mode
  • You can see it when the RayCast settings panel is open, but not in Ctrl+D mode yet :(
  • @PixelPizza I thought exactly the same, but I actually don't really need it. The preview when opening the RayCast settings panel (it should be called properties panel :dissapointed: ) is good enough.
  • I Just created a super nice thing with this!


    I already tried to do this in flowlab but it wasn't perfect.
    This time it's so much simpler and easy to make.

    The only that is left is a rope that connects the player to the wall AKA a visual thingy that makes it look cooler (doesn't affect the logic)

    If someone could create a rope without causing so much lag I could do an example game for this.
  • @PixelPizza hate to burst your bubble, but I’m ahead of you on that. Crimson Hunters
  • I’d still like to see this.
  • Maybe a “draw line” function that draws a line of select width from point A to point B
  • Crimson Hunters have a grapling hook? @CrimsonBlackGames
    Show me da wae


    The game is "Awakening" on the level "Village 2" (level 23)
    (Contains a little spoiler but no one cares xD)

    If you press shift and if the player have a white wall at +- 45º degrees it jumps to the location @grazer
  • Also did this Card Game Example with Ray Casting:

    To finish it (add more cards) I would need to have a feature that sends a message to the specific object that ray cast detected
  • @PixelPizza it was originally a grappling hook, but now it’s something else close
  • Well could u send the link so I can check it out

    Apparently looking up names works too
  • I'll test this when I have time, but it sounds like Pokemon trainer ! behaviors with extras.
  • Welcome back @Mhx Aîr
  • edited April 2018

    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.
  • edited April 2018
    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?
  • edited April 2018
    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:
Sign In or Register to comment.

| make games in your browser
@ 2017, All rights reserved.

Contact us

Get In Touch