I’m just joking,in other cases i’ll don’t try to help you ^^.
GET_GROUND_Z_FOR_3D_COORD(float x, float y, float z, float* groundZ, BOOL unk);
I see this returned value “float* groundZ” but i don’t see the second .Somebody else may can tell us .
The boolean say if ground is found at coords,else it retry until found.
And object spawn also underwater.
Tested with 3500 radius and seems to work pretty fine
Edit: more the radius is high more the spawning time is long but it don’t affect the positioning of the objects.(Maybe due to my “slow” laptop? I don’t know… Must be tested on a better computer.)
Edit 2: The second value returned is maybe the boolean??
Interesting topic, since I have tried to do the same thing for ped and vehicle spawns around the map. I ended up using a variant of this:
“https://github.com/crosire/scripthookvdotnet/wiki/Code-Snippets#force-groundztrue-water-depth-by-dilapidated”
But I still will get peds falling through the map sometimes in certain areas, other areas work fine. With Peds and vehicles they will fall around 200m then get placed at the nearest vehicle node, so it is not a showstopper, but I should revisit this when I get more motivation. I tried adding HasCollisionForModelLoaded to it but still did not work all the time. @mikou does yuor script also work for peds and vehicles? I may be over-complicating it. I’m wondering now if I need to get the Groundz for x, y, 1000 then do RequestCollisionAtCoord(x,y,Groundz) before spawning the ped there as well, which is the only thing I have not tried yet.
I’ll try it for you cause i’ve a test code so a think this easier for me to test it instead of you to modify your whole script.I’ll tell you when done.
Thanks. With peds I am finding groundz and then adding like 1 to 3 units to the groundz coordinate since iirc peds will spawn at their waist and will fall through.
So tested in the same conditions than objects and work perfectly with peds and cars also spawn in water(rivers,lakes etc).
To go further i’ve test in North Yankton and work to.
The only case that cause it do nothing is when in the middle of the ocean so this is no big deal ^^.