- Home /
Problem is not reproducible or outdated
Physics Raycast taking forever
Hey,
I am doing some physics ray cast to adapt my terrain to the objects on top of it. I'm doing this by laying a grid over the terrain but actually calculating a grid of 100x100 already takes 5-6 secs and a grid of 500x500 takes about 3-4 minutes,
I mean I could take that as I can wait that long but I actually need to calculate a grid of 6000x6000 to calculate the entire mesh of my map. so already 1000x1000 takes so long that I actually think that unity crashes (waited over 20 minutes without any reaction).
So I calculate that in the editor on a Macbook Pro (from 2013). Surely not the most powerful device but the best I actually have.
I also already change form a sphereCast to a simple rayCast but the performance difference was pretty much nothing (5 or 6 seconds on a 500x500 grid).
So is there anyway to calculate it faster?
I already thought about dividing the grid into multiple smaller grids but actually I was unable to set up a system which does it good.
If anybody has a idea how I could calculate this, that would be great.
Does the grid necessary needs to be from ray casts ? If yes, then optimizing code is always an option i think.
Example of code maybe, or use terrain setheights and get heights ins$$anonymous$$d of ray casts.