Jump to content
Sign in to follow this  
stilton

getting ai really close to a chair? (ai object avoidance)

Recommended Posts

Hi,

i have an ai with a script who runs up to a chair but i cant seem to get him closer than say 2 meters..

and id really like him to be almost ontop of it before i trigger the ambientAnim function...

I've tried most things i can think of, off the top of my head, but that's probably not saying much!

cheers if anyone can point me in the right direction.

_unit setUnitPos "UP";
_unit setBehaviour "CARELESS";

_unit disableAI "FSM";
_unit disableAI "TARGET";
_unit disableAI "AUTOTARGET";
_unit disableAI "AIMINGERROR";
_unit disableAI "SUPRESSION";
_unit disableAI "PATHPLAN";
//_unit disableAI "THREAT_PATH";
//_unit assignAsCargo Waldos_Chair;
//[_unit] orderGetIn true;
//_unit enableCollisionWith Waldos_Chair;
_exactPos = Waldos_Chair modelToWorldVisual [0,0,0];
while {_unit distance (position Waldos_Chair) > 2}  do {
//_done = moveToCompleted _unit;
if (unitReady _unit) 
	then {
	//_unit disableAI "MOVE";
	_moveWP = (group _unit) addWaypoint [ _exactPos , 0]; 
	_moveWP waypointAttachVehicle Waldos_Chair;
	_moveWP setWaypointType "GETIN";
	_moveWP setWaypointCompletionRadius 0;

	//_moveWP setWaypointType "GETIN";
	//[group _unit, 1] setWaypointCompletionRadius 1;   
	};
//_unit moveTo (position Waldos_Chair);
sleep 2;
};


it's almost like there's some built-in collision promixity 'bubble' flux capacitor* around the chair object and he just wont go inside it :( as he seems to dislike other editor placed objects in the same fashion, not wanting to get too close... But obviously as i want him to sit in the chair, the closer the better...

thanks!

*sorry had to

Share this post


Link to post
Share on other sites

I'm not an AI guy but I can suggest a hacky approach, when unit is close to a chair, manually rotate him towards chair with setDir or setVectorDir and then keep setting walk forward action until he reaches the chair with _unit playActionNow "WalkF"

Share this post


Link to post
Share on other sites

Wow thanks.. i had considered considering using setDir but didn't know of a good way i could force the unit forward, thanks for telling me about... playActionNow "WalkF"

and since all my coding is 'hacky', this should fit right in :D

Share this post


Link to post
Share on other sites

You can also give the AI a waypoint 2m further away than the chair to actually get him close to it.

AI move commands will be fulfilled if they're a specific distance from their expected destination (~2m for infantry, ~6m for cars and ~100m for aircrafts), that's why you can't get him closer than 2m to a chair.

Share this post


Link to post
Share on other sites

You misspelled "SUPPRESSION" in the part of the script that says: this disableAI "SUPPRESSION";

Aside from that, you could try a command like:

_unit attachTo [Chair1,[0,0,0]]; (You'll have to adjust the [0,0,0] values until it looks like the unit is actually in the chair correctly, otherwise it may look weird)

The only problem with attachTo is it will instantly teleport/attach the unit to the object he is being attached to, but if the chair is right in front of him, it won't look that bad since units teleport into vehicles all the time when getting in and out of them. A way you could make it look smooth would be to do the tedious process of playing animations of the unit walking towards the chair object. If the unit doesn't get close enough because of animation/collision issues, you can try the even more tedious process of having a lot of attachTo commands in between sleep delays, with the vector values bringing the unit closer and closer. Hope that makes sense. Those are the only ways I know of doing.

[EDIT]

Oh, and do the commands for disabling AI "PATHPLAN" and "THREATPATH" actually exist and function in ArmA 3?

Share this post


Link to post
Share on other sites
You misspelled "SUPPRESSION" in the part of the script that says: this disableAI "SUPPRESSION";

Aside from that, you could try a command like:

_unit attachTo [Chair1,[0,0,0]]; (You'll have to adjust the [0,0,0] values until it looks like the unit is actually in the chair correctly, otherwise it may look weird)

The only problem with attachTo is it will instantly teleport/attach the unit to the object he is being attached to, but if the chair is right in front of him, it won't look that bad since units teleport into vehicles all the time when getting in and out of them. A way you could make it look smooth would be to do the tedious process of playing animations of the unit walking towards the chair object. If the unit doesn't get close enough because of animation/collision issues, you can try the even more tedious process of having a lot of attachTo commands in between sleep delays, with the vector values bringing the unit closer and closer. Hope that makes sense. Those are the only ways I know of doing.

[EDIT]

Oh, and do the commands for disabling AI "PATHPLAN" and "THREATPATH" actually exist and function in ArmA 3?

highly unlikely. all pathfinding is done engine side anyways, also "MOVE" is probably as close as you will get to something like that.

Share this post


Link to post
Share on other sites

with all due respect... absolutely no offence intended but the last 3 replies aren't very helpful :D

I think to be honest, samatra nailed it with his 'hacky' solution because it actually deals with the question i asked. The other replies don't

i said: ai with a script who runs up to a chair but i cant seem to get him closer than say 2 meters

So, its the " getting close-to the chair " that i'm having problems with... because of some sort of, (as i said -- but ill repeat) some sort of what feels like a collision mesh around the chair itself. Try this in the editor yourself before giving feedback, if your chair objects allow AI civilians to run -through-* them, by placing a waypoint behind them, must be something im doing wrong...

Note that i'm saying through here.. Because if your chairs, in your editor missions force the civilian to pass -around- them.. then the civilian is also, for you too, using some sort of pathfinding/collision detection with an extremely large collision mesh attached to the chair. (Which, tbfh, needs adjusted. ).

You can also give the AI a waypoint 2m further away

I've tried making a waypoint with scripting with a completion radius of 0, and 0.5 meters On the chairs world coordinates and loop it, and the guy just runs a 3m circle around the chair...

Also... the 'attachTo' command is not relevant to the question.. I can get him to animate into the chair after the fact, its the actual getting close...

( Although i do appreciate you explaining another hacky way of getting him to make small teleports towards it lol - +1 for imagination i guess :D )

Re: PATHPLAN / THREATPLAN is taken from either BIsims or Take-on biki... the engine does not throw any scripting errors (with -showScriptErrors on) when disabling this ai-subset... and the ai did seem to respond with a more direct route... So i would say that 'pathplan' does actually do something... But i have no idea in truth.

Edited by Stilton

Share this post


Link to post
Share on other sites
Re: PATHPLAN / THREATPLAN is taken from either BIsims or Take-on biki... the engine does not throw any scripting errors (with -showScriptErrors on) when disabling this ai-subset... and the ai did seem to respond with a more direct route... So i would say that 'pathplan' does actually do something... But i have no idea in truth.

You can pass disableAI any string without getting an error, but only certain strings will actually have an effect. PATHPLAN/THREAT_PLAN are VBS-specific parameters that are not recognized in ArmA. If they were recognized, you'd have had no problem getting your AI to walk up to -- or even right through -- your chair.

Share this post


Link to post
Share on other sites

are you certain of this?

I ask because, again, on disabling Pathplan / Threatplan, i noticed the ai actually getting stuck on objects [ the edge of a house, i believe it was ] inbetween, attempting to move towards the chair...

( - and Since all the houses have positions around them for viable cover, i assumed at the time, that it may have something to do with "path planning" of routes between startpoint/destination avoiding objects on the way. )

..But, i don't say that with any certainty/authority... Because i was trying a lot of things and i'm aware of my own failings when it comes to not following correct scientific method of change-one-variable-at-a-time-and-test. :D

Share this post


Link to post
Share on other sites

You say it with such certainty i believe it this time.

:D

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  

×