Jump to content
Nicole_UK

AI not moving to waypoint after animation

Recommended Posts

im making a single player mission and at the start of the mission the aI are stood together in waiting and idle animations... then when the player comes near them into a trigger there is a 10 second wait then the AI stop their waiting/idle animations and proceed to a waypoint.

 

The problem is they wont move to their waypoint... Iv managed to get them to stop the animation using 

UNIT switchmove "";

in the trigger but they dont move to the waypoints they just stand still... I have synced the trigger to the waypoint but still nothing...

 

any help please??

Share this post


Link to post
Share on other sites

@Nicole_UK,

I'm not sure why your NPC isn't moving but I am sure that triggers and waypoints are holding you back!

[NPC_0, NPC_1, NPC_2] spawn {
	waitUntil { sleep 1;
		if (player distance (_this select 0) < 10) then {
			{
				_x spawn {
					sleep 10;
					_this switchMove "";
					_this enableAI "ALL";
					_this doMove (_this getVariable ["move_pos", (_this modelToWorld [100, 100, 0])])
				}
			}forEach _this
		};
		(player distance (_this select 0)<10)
	}
};

Uses the first NPC in the array as an area center, 10 m. When player enters the area wait 10 seconds and release the NPCs listed in the array from their animation. Send them to the variable "move_pos" default: 100 meters that way. Exit loop.

Have fun!

  • Like 3

Share this post


Link to post
Share on other sites

Thank you for helping me!

 

Do i put that code in the trigger activation or the waypoint activation?

 

And what im trying to do is when i start the mission have an ai squad stood around "waiting" for me to walk near them then they move to a waypoint (a move and get in vehicle waypoints to be precise)...  will this code affect just the ai im wanting it to or will it affect all nearby AI as there is lots of other ai stood about that i dont want affected...

Share this post


Link to post
Share on other sites

@Nicole_UK,

Quote

Do i put that code in the trigger activation or the waypoint activation?

Paste the script into the init field of one of the units. The first NPC is the "trigger area" (10 m). No waypoints or triggers required.
 

Quote

will it affect all nearby AI as there is lots of other ai stood about that i dont want affected

It will only affect the units listed in the array.
 

I edited the script so the NPCs listed in the array will move to, then board the vehicle listed last in the array,

[NPC_0, NPC_1, NPC_2, truck_1] spawn {
	private _veh= _this select (count _this) -1;
	waitUntil { sleep 1;
		if (player distance (_this select 0) < 10) then {
			{
				[_x, _veh] spawn { params ["_unit", "_veh"];
					sleep 10;
					_unit switchMove "";
					_unit enableAI "ALL";
					_unit doMove (getPos _veh);
					waitUntil {sleep 1; _unit distance _veh < 5};
					_unit moveInAny _veh
				}
			}forEach _this
		};
		(player distance (_this select 0)<10)
	};
	waitUntil {sleep 1; {_x in _veh} count _this == count _this -1};
	driver _veh spawn {_this doMove (_this getVariable ["move_pos", (_this modelToWorld [0,0])])};
};

Have fun!

Edited by wogz187
added unit variable for vehicle destination once boarded
  • Like 2

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

×