Is it efficient to use multiple raycast2D ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By supper_raptor

i am currently using raycast2D for guns in my game and i am thinking about using raycast2D for bot navigation . I will be using 4 raycasts for each bot and there will be at least 24 bots at at time.

Will there be any performance drop?
Target platforms are android and PC.

:bust_in_silhouette: Reply From: Zylann

Raycasts should be reasonably fast, but the best way to know if they are fast enough in your particular game is to profile it.
Check on your computer if 24 bots perform well enough, and then test the same thing on device. You may have to use the Godot profiler to check where the bottlenecks might appear: Overview of debugging tools — Godot Engine (stable) documentation in English

How well do they perform when compared to Area2d ?

supper_raptor | 2020-04-08 18:15

It really depends on the shape used. I’d say raycasts can be faster, but you may need more to reproduce the same functionality some Area2D setups can solve better.
The best answer remains profiling. Measure how it performs, find bottleneck, then act on it.

Zylann | 2020-04-08 18:59

Yeah they are efficient , even working with 100 bots !

supper_raptor | 2020-04-09 11:13