Jump to content
Sign in to follow this  
-ami- mofo

having trouble with setdir

Recommended Posts

Hi gents,

I have two units spawned on a marker via a trigger with this in the .sqf....

sg1 = [getMarkerPos "sg1spawn", EAST, ["O_Soldier_TL_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; 
{_x allowFleeing 0} forEach units sg1;

Trouble is I want them to face a different direction. I've tried messing with setDir by adding sg2 setDir 180 to the bottom of what I already

have but that just made the units snot spawn at all.

I'm guessing that sg2 setDir 180; must have to be incorporated somewhere amongst the 1st line? But I don't know how exactly to do that. :confused:

Thanks

Share this post


Link to post
Share on other sites

you could try it like this:

sg1 = [getMarkerPos "sg1spawn", EAST, ["O_Soldier_TL_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; 
{_x allowFleeing 0;_x setdir random 360} forEach units sg1;

this will give every unit a random direction, if you need to give a specific direction to a specific unit you can do it with

(sg1 select 0) setdir 180;

Share this post


Link to post
Share on other sites

Isn't this because they are members of a group? They will all face the direction of the group leader.

Share this post


Link to post
Share on other sites

I've actually changed things a little since my post and I now just have a single soldier spawn and am trying to make it face south so I did this based on Grumpy's code...

_sg2 = [getMarkerPos "sg2spawn", EAST, ["O_Soldier_F"]] call BIS_fnc_spawnGroup;
{_x allowFleeing 0; _x setdir 180} forEach units _sg2;

Which spawns a dude facing south ;).... but a second after spawning he rotates on the spot and faces north :confused_o:

Share this post


Link to post
Share on other sites
but a second after spawning he rotates on the spot and faces north :confused_o:

This confirms my theory. He's rotating back to the formation direction.

Share this post


Link to post
Share on other sites

Try doStop in there:

_sg2 = [getMarkerPos "sg2spawn", EAST, ["O_Soldier_F"]] call BIS_fnc_spawnGroup;
{_x allowFleeing 0; doStop _x; _x setdir 180} forEach units _sg2;

Share this post


Link to post
Share on other sites

Ah well done, DA. I was struggling to remember how I got around this in my CQB placement scripts. You're right, doStop should temporarily break his links with the group leader and allow him to face whatever direction you want.

Share this post


Link to post
Share on other sites
This confirms my theory. He's rotating back to the formation direction.

This is just a single unit though, not part of a group.

Try doStop in there:

_sg2 = [getMarkerPos "sg2spawn", EAST, ["O_Soldier_F"]] call BIS_fnc_spawnGroup;
{_x allowFleeing 0; doStop _x; _x setdir 180} forEach units _sg2;

Didn't work either mate. Still rotates to the north after spawning.

I basically cheated by adding a move marker a couple of feet away from the spawn marker, south of the spawn marker. That way he takes a couple of steps to the south and stays facing that direction when he stops. A bit dodgy but it works.

_sg2 = [getMarkerPos "sg2spawn", EAST, ["O_Soldier_F"]] call BIS_fnc_spawnGroup; 
{_x allowFleeing 0} forEach units _sg2;

_waypoint0 = _sg2 addwaypoint[getmarkerpos"sg2move1",0];
_waypoint0 setwaypointtype"Move";

Share this post


Link to post
Share on other sites

Hi mate I tried that too somewhere along the line but to no avail.

Share this post


Link to post
Share on other sites

setformdir won't help, it just sets the formation direction which is functionally identical to setting the group leaders direction - the rest of the group just do the same.

---------- Post added at 10:54 ---------- Previous post was at 10:48 ----------

Right after the doStop, try a doWatch. This definitely works for me.

Just remember that dowatch doesn't take a direction. You don't tell it to watch a direction, but an object or a position. There's a relative position function in the functions library to help with this.

---------- Post added at 10:57 ---------- Previous post was at 10:54 ----------

// by Zapat and Tankbuster
//Edited by SPUn
#define THIS_FILE "fn_p_relativePos.sqf"
#include "x_setup.sqf"

private ["_p1", "_dir","_dst","_r","_alt"];
_p1 = _this select 0;
_dir = _this select 1;
_dst = _this select 2;

_alt = 0;
if (count _this > 3) then {_alt = _this select 3};

_r = [(_p1 select 0) + sin _dir * _dst,(_p1 select 1) + cos _dir * _dst,_alt];

_r

or compile and call this baby;

Share this post


Link to post
Share on other sites

setdir needs to be run where the unit is local, finish this with a setpos and all the other clients should see the unit pointing in the right direction as this updates the unit fully to the other nodes. Just one of those finnicky arma things.

Share this post


Link to post
Share on other sites
This confirms my theory. He's rotating back to the formation direction.
Thats why i suggested setFormDir. If the formation is pointing the direction you want him to face then the unit is not going to rotate back to the form direction.???

sg2 = [getPos player, west, ["B_Soldier_F"]] call BIS_fnc_spawnGroup;  { group _x setFormDir 180; _x allowFleeing 0; _x setdir 180} forEach units sg2;

Worls fine here. soldier spawns in and stays facing 180 (South). Without the setFormDir he rotates to face North

Share this post


Link to post
Share on other sites

Perhaps I misinterpreted the question, but I got the impression he wanted to have individual members of the squad facing different directions. setFormDir sets them all to face the same direction.

Share this post


Link to post
Share on other sites
Perhaps I misinterpreted the question, but I got the impression he wanted to have individual members of the squad facing different directions. setFormDir sets them all to face the same direction.

Ah could be me Tankbuster , I was going off of post #4 where OP said hed changed things to a single unit... NM

Share this post


Link to post
Share on other sites
Thats why i suggested setFormDir. If the formation is pointing the direction you want him to face then the unit is not going to rotate back to the form direction.???

sg2 = [getPos player, west, ["B_Soldier_F"]] call BIS_fnc_spawnGroup;  { group _x setFormDir 180; _x allowFleeing 0; _x setdir 180} forEach units sg2;

Worls fine here. soldier spawns in and stays facing 180 (South). Without the setFormDir he rotates to face North

Cheers man works a treat! :)

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  

×