SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/06/2020, 03:33 AM   #1
Kucin666
Big Clucker
 
Kucin666's Avatar
 
Join Date: Apr 2014
Location: Indonesia
Posts: 69
Reputation: 5
Question How to get z ground from roof building

Hello guys, I'm trying to get the z position using colandreas / mapandreas with that function, but I only get the z position from the building object, can I get the z ground position like the ground from the roof or the top building? I see Pathfinder can read objects, but is it for npc? thank you
__________________
Haaa
Kucin666 is offline   Reply With Quote
Old 30/06/2020, 01:48 PM   #2
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,774
Reputation: 619
Default Re: How to get z ground from roof building

The collision data does not contain info whether or not a surface is ground or building. Even the pathfinder doesn't know what's the actual ground or top of a building, it just detects height differences that NPCs cannot move over/through.

One way to detect the actual ground would be using path data (Ped Nodes and Vehicle Nodes are only placed on the ground) or the object model (by getting the model's category, for example building/lamp post/road). But that is not 100% accurate either and you would need to gather most of the data yourself I think.
NaS is offline   Reply With Quote
Old 01/07/2020, 04:47 AM   #3
Kucin666
Big Clucker
 
Kucin666's Avatar
 
Join Date: Apr 2014
Location: Indonesia
Posts: 69
Reputation: 5
Default Re: How to get z ground from roof building

Quote:
Originally Posted by NaS View Post
The collision data does not contain info whether or not a surface is ground or building. Even the pathfinder doesn't know what's the actual ground or top of a building, it just detects height differences that NPCs cannot move over/through.

One way to detect the actual ground would be using path data (Ped Nodes and Vehicle Nodes are only placed on the ground) or the object model (by getting the model's category, for example building/lamp post/road). But that is not 100% accurate either and you would need to gather most of the data yourself I think.
I have thought if using Pathfinder, the roof position is obtained when the Z position decreases dramatically with a short distance, but I still don't know about it and need to see about pathfinder, but maybe I can use path data but maybe not easy and there is a combination, because every place has a difference, thank you for your advice
__________________
Haaa
Kucin666 is offline   Reply With Quote
Old 01/07/2020, 07:30 PM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,774
Reputation: 619
Default Re: How to get z ground from roof building

Quote:
Originally Posted by Kucin666 View Post
I have thought if using Pathfinder, the roof position is obtained when the Z position decreases dramatically with a short distance, but I still don't know about it and need to see about pathfinder, but maybe I can use path data but maybe not easy and there is a combination, because every place has a difference, thank you for your advice
Technically that is correct, but it applies to other structures as well (for example a brigde or hill over a road). So the Z difference alone is not a sufficient criteria I think.

For a start you could use the path data from FCNPC to get valid spawn positions for NPCs on roads, so they would at least begin in proper positions (and not spawn somewhere on a roof or similar). Using the correct functions and logic with ColAndreas makes this already quite effective, for example by avoiding large structures and too steep surface angles (CA_RayCastLineAngle) you can have the NPCs almost always in valid positions when freely roaming (not sure what you use the NPCs for, I assume zombie-like roaming around the map).
NaS is offline   Reply With Quote
Old 01/07/2020, 07:55 PM   #5
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,135
Reputation: 215
Default Re: How to get z ground from roof building

Reuse last coordinates, increase Z for ~2.0 and run it from that height downwards on new coordinates. That is what i did to enable NPC's to walk inside tunnels and under the bridges. Also MTA has a good array with landmasses, road's and buildings, if you use that it will probably cover 90% of your uses and only leave some edge cases.
DRIFT_HUNTER is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Roof Object Help? Junkyard145 Server Support 6 27/01/2013 02:04 AM
[Map] Roof House scottygraham1990 Maps 13 28/12/2012 10:54 PM
Barricade is in the ground, How can I make it above ground? [TC]XxJuggaloxX Scripting Help 1 13/01/2012 02:29 AM
Has vehicle no roof? thimo Scripting Help 5 10/01/2012 03:11 PM
Falling through the ground while exiting a building/house omfggus Help Archive 28 14/06/2010 11:55 AM


All times are GMT. The time now is 05:06 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.