- Home /
Question by
username707 · Jul 22, 2013 at 01:43 PM ·
terrainperformancertsray
Performance - is raycasting for ground on Update() optimal?
I got a bunch of RTS units - no rigid bodies and uneven terrain. For slopes everu unit scans terrain downward with Physics.Raycast. And it's brings performance down. Is there a way to do the same with less performance hit?
Comment
Answer by Eric5h5 · Jul 22, 2013 at 02:03 PM
If you're using a Unity terrain, use Terrain.SampleHeight instead. Otherwise use layers so that the raycasting is cast against the terrain only and not other objects.
$$anonymous$$uch obliged it's faster with Terrain.SampleHeight