What are advantages of using raycast_async() over raycast()? What are disadvantages? Why and when would it be a good idea to use raycast_async()?
Most of the time you want raycast for immediate raycasts on the same frame. Use async when it doesn’t matter when you get the result of a raycast.
I haven’t yet had a need for the async version. I use raycasts for platformer physics. Since I need the resulting collisions immediately, waiting for async results would not work because I might be waiting a few frames.
Maybe if you’re casting a bunch of rays and it is hurting performance, then allowing the rest of the game to continue instead of lock up would be something to consider. In this case, you would want to use the async version.
Thank you!
I’m generally trying to understand them more, so such insights are very helpful
Another thing, perhaps more technical, is that - should raycasts be given world positions?
In examples I see go.get_position to specify a raycast from game object’s origin, but in those examples world and local positions are the same, so it’s not answering the question if raycasts should be given world positions. I can’t find any info about it
there doesn’t seem to be any particular reason to use the asynchronous method. In my opinion, it’s just a legacy method when the Defold didn’t have a synchronous raycast yet.
in same coordinates that collision shapes have. World positions.