Jump to content
Sign in to follow this  
Handle1

[UNSolved] Creating an object any location on the map?

Recommended Posts

Hello again. I attempted to use a unit named Officer_WP as a place to go to. However my ai spawn, go into formation, and stay put without ever traveling to the officer_WP.

My source:

_makeUnits = {
_grp = createGroup west;
for [ {_i = 0}, {_i <= 5}, {_i = _i + 1} ] do 
{
_newAi = "B_soldier_M_F" createUnit[position player, _grp];
if (isNil "_newAi") then {
hint format ["_newAi was not created!!!"]
}
else {
[_newAi] join player;
hint format ["_newAi was created."];
};

}
};

_moveUnits = {
_unitArray = units player;
if (isNil "_unitArray") then {
hint format ["Units were not retrieved for movement!"];
}
else {
{
(_x ) doMove (position Officer_WP);
}forEach _unitArray;
}
};


_positionAlpha = createVehicle ["B_MBT_01_cannon_F", position player , [], 0 , "CAN_COLLIDE" ]; //Just trying something out. This is rather useless at this point!
if ( isNil "_positionAlpha" ) then {hint format ["Position was NOT created!"] }
else {
hint format ["Position was created!"];
};

call _makeUnits;
hint format ["Five units created."];

call _moveUnits;

hint format ["Units should be moving now."];

I think the reason this isn't working is the line in bold. Specifically the command "units" which returns an array containing the units in the group. There was something on the wiki that said this function doesn't work in MP if called by initline functions or init eventhandlers. In this case I have it being called from a script called "init.sqf" which loads a file called "loader.sqf" which then loads all of my scripts. Could that be why my AI do not proceed to the Officer_WP AI object? I have placed a unit in the mission with that specific name too. Maybe THAT'S the problem; the object isn't global in the mission file so I cannot access it.

One more question: how would I spawn an object somewhere without placing it in the editor first? I'm just interested in spawning things at an arbitrary location so that I can use it as a waypoint for personal learning and debugging.

Edited by Handle1

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  

×