PheNux Cam 0 Posted February 25, 2017 I'm working on a little script for my milsim unit and I'm creating a formations training board. This is my little spawnboard I created and I have a script that is going to spawn some ai in different formations, such as a wedge, line, column etc. Right now you are viewing the line. My issue is that when I spawn these guys in with the script I cannot get them to face my direction, they just default back to facing the north direction no matter what. I've been stuck on it for about 6 hours and tried everything, dowatch, lookat, setdir, setformdir, I even created another empty marker as a direction for them to watch towards if possible but nothing works. Here you can see a map view of what I have setup, the empty markers with the ai I've spawned, the spawnboard, and another empty marker as a potential direction to look at. Lastly, here is the code I'm working with. I have only been scripting for about a week now so I am still new to this all but i've managed to do this all from tutorials and constant study of the wiki though things are still confusing, please help thanks <3. Share this post Link to post Share on other sites
killzone_kid 1326 Posted February 25, 2017 What you need is setFormDir https://community.bistudio.com/wiki/setFormDir Share this post Link to post Share on other sites
PheNux Cam 0 Posted February 25, 2017 Yeah, I have been playing around with that but I feel that I may not be entering it properly. So far I have it this way [getMarkerPos "man1" setFormDir 270]; I have to use getmarkerpos man1 since it is my marker to spawn the man so it has to be my object. Then when I try the board I get an error. I still have difficulty comprehending what I am doing wrong but somehow I feel it might be simple.. like an error in syntax or something, can you give me an example to fix it properly? Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 This command is applicable to unit/group only, but you trying to apply it to coordinate array. Why you never read description of the commands before using them? 1 Share this post Link to post Share on other sites
PheNux Cam 0 Posted February 25, 2017 I did read over it like 100 times and tried to comprehend, but that is what happens when you are days new to something, I'm a bit slow stupid. Therefore, what would be the proper way to fix this then?? Share this post Link to post Share on other sites
beno_83au 1362 Posted February 25, 2017 getMarkerPos "man1" is returning a position array. So it essentially is doing this: [_x,_y,_z] setFormDir 270 As Serena said, it needs to be a unit, not a position. _unit setFormDir 270; Or {_x setFormDir 270} forEach (units _group); It'd be worth reading up on forEach and units in the command reference to learn more about them. Sorry, to add to this, i believe a further setDir is then needed, but check the link killzone kid posted, it should be in there. Share this post Link to post Share on other sites
PheNux Cam 0 Posted February 25, 2017 5 minutes ago, beno_83au said: getMarkerPos "man1" is returning a position array. So it essentially is doing this: [_x,_y,_z] setFormDir 270 As Serena said, it needs to be a unit, not a position. _unit setFormDir 270; Or {_x setFormDir 270} forEach (units _group); It'd be worth reading up on forEach and units in the command reference to learn more about them. Sorry, to add to this, i believe a further setDir is then needed, but check the link killzone kid posted, it should be in there. Thanks I'll work on it Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 1 hour ago, PheNux Cam said: Therefore, what would be the proper way to fix this then?? Something like: // spawn group (abstract line, replace with your own) private _group = [...] call BIS_fnc_spawnGroup; // order group to face 45' _group setFormDir 45; // rotate each unit of group {_x setDir 45} forEach (units _group); * fixed Share this post Link to post Share on other sites
killzone_kid 1326 Posted February 25, 2017 Just now, serena said: private _group = [...] call BIS_fnc_spawnGroup; I tried this but it doesn't work, it gives me error: Quote 19:28:17 Error in expression <private _group = [...] call BIS_fnc_spawnGroup;> 19:28:17 Error position: <...] call BIS_fnc_spawnGroup;> 19:28:17 Error Invalid number in expression Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 PheNux Cam, first line of code in my sample is abstract, it is introduced only to show how to "_group" variable initialized. private _group = [...] call BIS_fnc_spawnGroup; // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ abstract part, replace with your own code Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 35 minutes ago, killzone_kid said: I tried this but it doesn't work, it gives me error: Nice error reporting. You just need to replace three dots with actual arguments from here and then everything will work fine :) Share this post Link to post Share on other sites
PheNux Cam 0 Posted February 25, 2017 28 minutes ago, serena said: PheNux Cam, first line of code in my sample is abstract, it is introduced only to show how to "_group" variable initialized. private _group = [...] call BIS_fnc_spawnGroup; // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ abstract part, replace with your own code Thanks for helping :) <3 Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 27 minutes ago, PheNux Cam said: Thanks for helping :) <3 // fixed last line {_x setDir 45} forEach (units _group); Share this post Link to post Share on other sites
Tankbuster 1733 Posted February 25, 2017 Perhaps I'm remembering incorrectly, but I thought all members of the group would go back to facing the direction of the group leader, even after individual units were given setdir commands? Share this post Link to post Share on other sites
serena 150 Posted February 25, 2017 Tankbuster, you're right. Individual unit rotating is ambigous in most cases. Just tested this code, all works fine: // init.sqf player addAction ["Spawn Team", { mygroup = [player modelToWorld [0,25,0], WEST, 5] call BIS_fnc_spawnGroup; player removeAction (_this select 2); player addAction ["Set Formation North", {mygroup setFormDir 0}]; player addAction ["Set Formation East", {mygroup setFormDir 90}]; player addAction ["Set Formation South", {mygroup setFormDir 180}]; player addAction ["Set Formation West", {mygroup setFormDir 270}]; }]; Sample mission: link Share this post Link to post Share on other sites