Jump to content
Sign in to follow this  
peterius

can't createUnit tried everything

Recommended Posts

I have seriously been messing with this for like six hours.

I have tried every way I could think of. I'm using "[(getPos player select 0) + 1, (getPos player select 1) + 1]" for the location? I actually think it worked once, with setPos, so I assume its fine.

And then I thought maybe you could only createUnit from a script file, that you couldn't do it from the trigger onactivate field. So I tried that with [] exec "script.sqs" and it runs the script, but it still won't create the damn unit.

Share this post


Link to post
Share on other sites
_unit = someGroup createUnit ["unit_ClassName", getPosATL player , [], 0, "CAN_COLLIDE"];

Share this post


Link to post
Share on other sites
_unit = someGroup createUnit ["unit_ClassName", getPosATL player , [], 0, "CAN_COLLIDE"];

You think its not spawning it because its too close? I think I've tried besides 1m as well. And is there a reason to use getPosATL instead of getPos?

I tried it, nothing.

I also tried some of the stuff I had been doing with getPosATL instead of getPos and different units in case the classname was bad, still nothing.

Edited by peterius

Share this post


Link to post
Share on other sites

If the unit your spawning is on a different side you will need to place at least one unit of that side on the map somewhere.

this will spawn a unit on your side and in your group.

_unit = group player createUnit [typeof player, getPosATL player , [], 0, "none"];

Share this post


Link to post
Share on other sites
If the unit your spawning is on a different side you will need to place at least one unit of that side on the map somewhere.

this will spawn a unit on your side and in your group.

_unit = group player createUnit [typeof player, getPosATL player , [], 0, "none"];

That's crazy. You're saying you can't spawn any unit that isn't placed on the map elsewhere? Anyway, I tried that and it didn't work. If there was some weird group error, would it would not say anything and just silently not spawn anything? (I have the -showScriptErrors thing on)

Edit:

I just suddenly got a dialog error message for a typo in one of the triggers I added yesterday. What? WHAT? And now magically it started adding units.

Yeah, thanks, that was it, I had to place a unit somewhere else on the map.

Something else isn't right either, I can't change the class name of the unit...

I tried changing the groups and now, despite working with a group name defined in an initialization field before, now the script can't find the group name, says its a bad variable. This is ridiculous.

Edited by peterius

Share this post


Link to post
Share on other sites

Well you need to create the units side before creating/spawing units. You can use createCenter or place a unit on the map, of the corresponding side. You can set his probability of presence to 0% aswell. Also, what classname are you trying to create?

Share this post


Link to post
Share on other sites

Using this should help you create vehicles of any side:

createcenter civilian;
createcenter east;
createcenter west;
createcenter resistance;
createCenter sideLogic;

I have found setting friendly options is sometimes necessary when there aren't any units of type on the map as well:

West setFriend [Resistance, 0];
West setFriend [East, 0];
West setFriend [West, 1];
East setFriend [Resistance, 0];
East setFriend [West, 0];
East setFriend [East, 1];
Resistance setFriend [East, 0];
Resistance setFriend [West, 0];
Resistance setFriend [Resistance, 1];

You only have to do that once. Then just create a new group when creating the unit (i.e. _civGroup = Creategroup civilian;)

Share this post


Link to post
Share on other sites

Yeah, thanks, I think I got it working.

Edited by peterius

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  

×