Jump to content
Sign in to follow this  
Koni

Naming a spawned unit ?

Recommended Posts

Scrapped...

Edited by Koni

Share this post


Link to post
Share on other sites

_ewp1 = enemyman1 addWaypoint [getMarkerpos "em1", 10];

_ewp1 = setWaypointType "SAD";

_ewp1 = setWaypointSpeed "NORMAL";

_ewp1 = setWaypointFormation "STAG COLUMN";

I suspect that this is the part causing the trouble. Which waypoint exactly are you setting the type, speed and formation off?. Regarding setWaypointFormation I don't think that will be used until after the waypoint is complete.

Try:

_ewp1 = enemyman1 addWaypoint [getMarkerpos "em1", 10];
_ewp1 setWaypointType "SAD";
_ewp1 setWaypointSpeed "NORMAL";
_ewp1 setWaypointFormation "STAG COLUMN";

I'll save sbsmac the trouble:

Use squint, "it saves lifes".

Share this post


Link to post
Share on other sites

Scrapped...

I have found out the way I was spawning units cannot be refered to afterwards in any triggers etc once they have been spawned, but this way you are meant to be able to name them and refere to them after spawning

"GUE_Soldier_AR" createUnit [getMarkerPos "enemymanmarker1", _groupAlpha,"loon1 = this ;

this addweapon {binocular}", 0.6, "corporal"]

taken from the BI wiki, but it does not work for me when I make it into a script to execute during a mission ?!?!

I guess this line names the spawned unit "loon1" then ? if it did spawn ?

Also, where would you specify the units side, like EAST, WEST and Resistance ?

Edited by Koni

Share this post


Link to post
Share on other sites
Also, where would you specify the units side, like EAST, WEST and Resistance ?

You have to create the group....

_group = createGroup EAST;

Then you do this...but you had it all wrong!

_wp = _group addWaypoint [_wayptpos, 10];

[_group , 1] setWaypointBehaviour "SAD";
[_group , 1] setWaypointType "NORMAL";
[_group , 1] setWaypointCombatMode "STAG COLUMN";

There's more to it so best you read the Wiki I think!

http://community.bistudio.com/wiki/addWaypoint

Never give up!! LOL!

Share this post


Link to post
Share on other sites

Thanks for your reply but I'm not trying to find out about waypoints for a spawned unit.

I am trying to find the correct code to spawn a unit and assign it a name, ie, create a doctor and have him called Sam, so I could then use it later in a trigger like, sam domove getmarkerpos etc etc.

Got it working to spawn a "named" unit, but to get it to spawn I have to assign it to a group already on the map, so the new spawned unit starts to run towards that group.

I can stop the unit from running with another trigger "newguy dostop" but can I spawn a unit that dosen't have to be assigned to another units group and simply be on it's own ?

Share this post


Link to post
Share on other sites

Just create a group for just him to be in. createGroup

Just change the group side to the correct one for your unit.

docsgrp = Creategroup east;

Just make sure you create this group before you create the unit.

Share this post


Link to post
Share on other sites

I tried that and couldn't get it to work.

I put docsgrp = Creategroup east; in the init file, also set it to a script file and tried it in a trigger, then tried spawning the unit and nothing spawned, but if I actually named another AI unit docsgrp or whatever name I was using as a group, then the spawn unit would spawn propperly, so that's how I am spawning units now, linked to an already existing AI unit, then deletevehicle the original unit used to get the other to spawn.

Share this post


Link to post
Share on other sites
I tried that and couldn't get it to work.

I put docsgrp = Creategroup east; in the init file, also set it to a script file and tried it in a trigger, then tried spawning the unit and nothing spawned, but if I actually named another AI unit docsgrp or whatever name I was using as a group, then the spawn unit would spawn propperly, so that's how I am spawning units now, linked to an already existing AI unit, then deletevehicle the original unit used to get the other to spawn.

I think the problem your having is with "center". You can not spawn units until it is defined.

Easiest way to fix is just put down a unit of the same faction as the ones you will be creating, and put his probability of presence to 0. That should fix your problems with the unit not spawning into that newly created group.(You can put him anywhere on the map, does not matter.)

I know kylania understands this a lot better than I, he is the one that gave me that fix and I know it works because I have used it in the past. He could probably explain it better than I as well.

Share this post


Link to post
Share on other sites

I already have units of all sides set on the map anyway, and have spare ones set to 0% presence to make sure too lol

Anyway, that's not really a problem anymore... but this one is, ha

Using this to spawn an empty vehicle...

_veh = createVehicle ["Ikarus", position logic1, [], 0, "NONE"];

works just fine, but I have been playing round with variations on facing direction and cannot figure it out.

What values do you type into that line to change the direction the vehicle is facing ?

I know the ,0 seems to change the placement from the center of the logic1 position, but I have tried all sorts of combinations to try and turn it on it's axis to face in a certain direction, but not having any luck with it.

I'd guess it's probably it's xyz values somehow ?

---------- Post added at 01:34 PM ---------- Previous post was at 12:58 PM ----------

Found it.

bus1 = createVehicle ["Ikarus", position logic1, [], 0, "bus1 = this;"];

bus1 setDir 155;

: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  

×