Game Development Community

Spawning on top of another object. Getting stuck.

by Robert Brower · in Torque Game Engine · 01/22/2003 (9:03 pm) · 1 replies

I placed a spawn sphere in my map but I have asteroids floating around and there is the possibility that one will be at the spawn location when I respawn. When that happens, I get stuck and I cannot move.

Is it feasible to do a radius search at the spawn sphere in a loop until it is confirmed to be clear before proceeding with creating a player there? Anyone have any problems with this?

#1
01/23/2003 (11:49 am)
It's pretty reasonable. I think Melv's foliage code does this sort of thing - it tries up to a hundred random locations to place things. If it can't find a free slot within a hundred tries, it warns in the console and keeps going. That way, if you try to put a million trees in a 100m radius, it puts somewhat fewer (and avoids self-intersection). I think you can turn this off for stuff like grass, of course.

I'd put it so that the code tries three or four randomly chosen points, and if they don't work, then it tries again later (either by telling the user, no dice, and then trying again when they click, or by scheduling a call back in a half a second or so.)