Jump to content
Sign in to follow this  
jw custom

How to check if position is on a road?

Recommended Posts

I'm using the

findEmptyPosition

isflatempty

commands to spawn objects in suitable places and they work great but is there anyway to check if a position is on a road?

Share this post


Link to post
Share on other sites

Hey thanks will try that, lol i searched for onroad on wiki without luck :p

Right now i'm trying with surfaceType :)

Share this post


Link to post
Share on other sites

isOnRoad ? "Check whether given position is on road. " What is that for ?

Share this post


Link to post
Share on other sites

Depending on whether you want to place something ON the road, or make sure it is OFF the road, I've also had luck with using nearRoads. Sometimes the AI pathfinding can be confused by objects placed too close to the road.... :)

Something like:

_roadArray = _position nearRoads _searchRadius;

Then have a conditional that counts the array - if there isn't anything in it, then it is not near a road. I'd suggest a search radius of about 20m to make sure a road is nearby.

Share this post


Link to post
Share on other sites

To see the isOnRoad command in action, try this:

nul = this spawn {
while {true} do {
	if (isOnRoad position _this) then {
		hintsilent "Yes.";
	} else {
		hintsilent "No.";
	};
	sleep 0.2;
};
};

Open the Editor, place down a player unit and copy/paste the above code in it's initline. Now run around and see if you're on a road piece or not.

Share this post


Link to post
Share on other sites
Depending on whether you want to place something ON the road, or make sure it is OFF the road, I've also had luck with using nearRoads. Sometimes the AI pathfinding can be confused by objects placed too close to the road.... :)

Something like:

_roadArray = _position nearRoads _searchRadius;

Then have a conditional that counts the array - if there isn't anything in it, then it is not near a road. I'd suggest a search radius of about 20m to make sure a road is nearby.

Thanks will try that aswell :cool:

The isOnRoad didn't work very well if at all(on sahrani) so i played a little around with surfaceType and it seems to work fine but need more testing in different areas :)

Share this post


Link to post
Share on other sites

As isOnRoad is introduced in ArmA2, it might not work on Armed-Assault-Maps. But that is probably the case with all those commands.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×