E
E
Espleth2015-03-29 22:54:37
Game development
Espleth, 2015-03-29 22:54:37

Speed ​​of Raycast in Unity3D?

How fast is Raycast in Unity3D? Will phones with weak processors be able to throw thousands of raycasts per second without much effort?
What it is for:
There is a 2d toy, which is a field of NxM cells, say, about 100x100. On each of the cells, the player either can stand up or cannot. You need to make the shortest route from point A of this field to point B. I don’t know if the algorithm is more efficient than exhaustive (or almost exhaustive) search, but in any case, you will have to call Raycast many times to find out if you can make a path through the cell or no. Will this not kill performance, or is it worth having a two-dimensional array under the playing field, in which it will be indicated whether it is possible to pass through the cell or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Kitmanov, 2015-03-29
@Espleth

On each of the cells, the player either can stand up or cannot. You need to build the shortest route from point A of this field to point B.

A* . Even for sure there are ready-made assets on this topic.

S
Stanislav Silin, 2015-03-30
@byme

You have chosen some very costly method ... it will not be easier to create a banal matrix (world map) and constantly update it when moving (add / move / remove obstacles). In terms of speed, this will be much more efficient than Raycast, since it does not require calls to the physics engine at all. And there are a lot of methods for finding a path along the matrix, the same A * as already written ... Plus, you will not be tied to Unity3d.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question