Find the nearest Ground Z Position.
#1

Hi guys, first, sorry for my bad english.

10 months ago, i tried to make a soccer system, with a stadium etc. It was really funny, and I had no problem. But few times ago, i had an idea: be able to play soccer everywhere around San Fierro.
But the Ground Z position was a problem. I didn't know what was the Z ground position for each X and Y pos. So i finally use the MapAndreas plugin (later, the one by RyDeR' because it takes less memory.) It was working good, but i finally found a problem that i never thought about: MapAndreas give us the higgest position of the ground.

So now i have some questions: how to find the nearest ground position for a given mark (X and Y positions) ?

Do you have some ideas or solutions ?
I have long thought that I needed to save all the Z position below each bridge around San Fierro, and make a function that check if the ball the the player shooted need to go to the lowest or the higgest Z pos.

Thank you for giving me a little of your time by looking for a solution with me.

And one more time, sorry for my bad english.
Reply
#2

Maybe SetPlayerPosFindZ?
Reply
#3

Did you read what i wrote ?
Quote:

i finally use the MapAndreas plugin[...] but i finally found a problem that i never thought about: MapAndreas give us the higgest position of the ground. [...] So, How to find the nearest ground position for a given mark (X and Y positions) ?

However, thank you for trying to help me
Reply
#4

MapAndreas gives correct Z - honestly, your suggestion about saving all the Z position would be really bad. That's why that plugin and include were made.
Reply
#5

No, MapAndreas give the highest Z pos, but if you're under a bridge, it'll never give you the Z position under the bridge. It will always give you the Z position of the bridge: the highest position. Me, I want to have the nearest Z position so, if you're on the bridge it give you the bridge Z position and if you're under the bridge, it give you the land Z position(the Z position under the bridge). I hope you understand what i mean.
Reply
#6

EDIT: I deleted this post because it's not useful
Reply
#7

I've created a few custom buildings in my gamemode and I've created an override of sorts as below:

pawn Код:
GetZFromXY ( Float: X , Float: Y , & Float: Z )
{
    MapAndreas_GetZ_From2DCoord ( X , Y , Z );

    if ( X > OverrideXMin && Y > OverrideYMin && X < OverrideXMax && Y < OverrideYMax )
    {
         Z = OverrideZ;
    }
}
Where Override values are the X and Y values for the area below the bridge and Z is the height below the bridge.

Very basically, this just gets the Z coord from Map Andreas but will force a different output if the X and Y coordinates fall within the "override" area (in this case, under the bridge).
Reply
#8

MapAndreas is alright but overall is not even close to acceptable in terms of collision detection. The only real solution is so make a replacement for Map Andreas by simulating the San Andreas map in a plugin and doing collision calculations this way for example.

pawn Код:
GetNearestFloorZ(playerid, &zheight);
Reply
#9

Quote:
Originally Posted by WrathOfGenesis
Посмотреть сообщение
I've created a few custom buildings in my gamemode and I've created an override of sorts as below:

pawn Код:
GetZFromXY ( Float: X , Float: Y , & Float: Z )
{
    MapAndreas_GetZ_From2DCoord ( X , Y , Z );

    if ( X > OverrideXMin && Y > OverrideYMin && X < OverrideXMax && Y < OverrideYMax )
    {
         Z = OverrideZ;
    }
}
Where Override values are the X and Y values for the area below the bridge and Z is the height below the bridge.

Very basically, this just gets the Z coord from Map Andreas but will force a different output if the X and Y coordinates fall within the "override" area (in this case, under the bridge).
It was my first idea. But i think that what [uL]Pottus said make more sense.
Thank you too guys, you won rep+
Reply
#10

Send me some more layers for the heightmap and ill add them to fix that. The problem is, that its extremely difficult to get the different heights for the same x/y coordinates. Overriding works, but im sure you dont wanna get all the override areas by hand for whole SA. Using the objects also wont work, as you dont know how big the objects are (you could use *****' list with the object collision spheres, but this will be really inaccurate, as skyscraper would look like a giant sphere with them).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)