BlackbirdSD 15 Posted November 25, 2020 If I have a tower named T1 that has random start positions, how do I get an AI unit to start on the roof of that tower? Thanks Share this post Link to post Share on other sites
JohnKalo 657 Posted November 25, 2020 A solution would be to attach an object like an invisible helipad or a Helper that is hidden on the tower. Then just use: sleep 1; //so as for the tower to get into position NameOfUnit setpos (getposATL NameOfHelper); or sleep 1; //so as for the tower to get into position NameOfUnit attachTo [NameOfHelper, [0.0, 0.0, 0.0]]; detach NameOfUnit; or directly sleep 1; //so as for the tower to get into position NameOfUnit attachTo [T1, [0.0, 0.0, NeededHeight]]; detach NameOfUnit; Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 26, 2020 18 hours ago, JohnKalo said: A solution would be to attach an object like an invisible helipad or a Helper that is hidden on the tower. Then just use: sleep 1; //so as for the tower to get into position NameOfUnit setpos (getposATL NameOfHelper); or sleep 1; //so as for the tower to get into position NameOfUnit attachTo [NameOfHelper, [0.0, 0.0, 0.0]]; detach NameOfUnit; or directly sleep 1; //so as for the tower to get into position NameOfUnit attachTo [T1, [0.0, 0.0, NeededHeight]]; detach NameOfUnit; I tried the direct method and it works great without the "sleep 1;" . I get an error when using the sleep that says '|#|sleep 1;s1 attachTo [t3, [0.0, 0.0, 5]];...' Error Generic error in expression. What does that mean? Was sleep 1 meant to pause for 1 second? How do I rotate the unit? I am putting this command in the units Init T3 is my tower and s1 is my unit Thanks Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 26, 2020 Now that I got a guy in the tower, is it possible for him to walk around a bit on the same floor that he starts? Share this post Link to post Share on other sites
Joe98 92 Posted November 26, 2020 Place something small on top of the tower such as a compass. Name the compass start1 Name yourself blue1 blue1 setpos getpos start1 . Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 26, 2020 9 hours ago, Joe98 said: Place something small on top of the tower such as a compass. Name the compass start1 Name yourself blue1 blue1 setpos getpos start1 . But then I need to worry about attaching that small item to the tower. How do I get them to roam around on the roof of the tower after they spawn there? Share this post Link to post Share on other sites
Joe98 92 Posted November 26, 2020 You don't need to attach it. By experimentation, you place the compass on top. After you get it right, you click on the compass and then you know the coordinates. You can practise by trying to place a compass on a table. Then start the mission and see if you can pick up the compass. If you can pick it up, it means you have done it right. It takes a bit of experimentation to get it right. To make a man patrol around the roof you need to give waypoints. As he has appeared at random, unfortunately, you need to use scripted waypoints. Scripted waypoints can be found here: https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 Start, by using scripted waypoints on the ground. Then use a bern and use scripted waypoints on the top of a bern. The do it on your tower. Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 27, 2020 1 hour ago, Joe98 said: You don't need to attach it. By experimentation, you place the compass on top. After you get it right, you click on the compass and then you know the coordinates. You can practise by trying to place a compass on a table. Then start the mission and see if you can pick up the compass. If you can pick it up, it means you have done it right. It takes a bit of experimentation to get it right. To make a man patrol around the roof you need to give waypoints. As he has appeared at random, unfortunately, you need to use scripted waypoints. Scripted waypoints can be found here: https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 Start, by using scripted waypoints on the ground. Then use a bern and use scripted waypoints on the top of a bern. The do it on your tower. Remember that my tower moves to random points so how does the compass follow if not attached? Is it possible for you to show me a small example of what a scripted waypoint would look like? What is a "bern"? Thanks Share this post Link to post Share on other sites
Larrow 2822 Posted November 27, 2020 Put a tower in an empty test map(VR) and name it T1. Add yourself as the player, go in the tower and stand where you want the soldier to start at, and then again for each place you want him to waypoint too. At each position run this code in the debug console... T1 worldToModelVisual getPosATLVisual player; ...note down the returned arrays. Then in your missions code after you have moved the tower, run... _savedPositions = [ [ 0, 0, 0 ], //<-- eg replace with start position //... <-- Add as many waypoint position as required //... ]; _startPos = _savedPositions deleteAt 0; _unit setPosATL ( T1 modelToWorldVisual _startPos ); { group _unit addWaypoint[ T1 modelToWorldVisual _x, 0 ]; //If its the last waypoint make the unit cycle if( _forEachIndex isEqualTo ( count _savedPositions - 1 )) then { _wp = group _unit addWaypoint[ T1 modelToWorldVisual _startPos, 0 ]; _wp setWaypointType "CYCLE"; }; }forEach _savedPositions; ...where [0,0,0] and //... are replaced with as many positions as you noted down, and _unit is a reference to the unit to place/waypoint. Think that works out right, untested. Share this post Link to post Share on other sites
JohnKalo 657 Posted November 27, 2020 Quote I get an error when using the sleep that says '|#|sleep 1;s1 attachTo [t3, [0.0, 0.0, 5]];...' Error Generic error in expression. What does that mean? Was sleep 1 meant to pause for 1 second? The sleep command cannot work in triggers. It works only in scripts. Yes the 1 means wait 1 second before continuing the script. Quote How do I rotate the unit? NameofUnit setDir 45; // will set unit1 to face North-East Also if the waypoints dont work cause .... Arma 3 .... maybe this will help: NameOfUnit doMove (getPosATL NameOfObject1); Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 28, 2020 17 hours ago, Larrow said: Put a tower in an empty test map(VR) and name it T1. Add yourself as the player, go in the tower and stand where you want the soldier to start at, and then again for each place you want him to waypoint too. At each position run this code in the debug console... T1 worldToModelVisual getPosATLVisual player; ...note down the returned arrays. Then in your missions code after you have moved the tower, run... _savedPositions = [ [ 0, 0, 0 ], //<-- eg replace with start position //... <-- Add as many waypoint position as required //... ]; _startPos = _savedPositions deleteAt 0; _unit setPosATL ( T1 modelToWorldVisual _startPos ); { group _unit addWaypoint[ T1 modelToWorldVisual _x, 0 ]; //If its the last waypoint make the unit cycle if( _forEachIndex isEqualTo ( count _savedPositions - 1 )) then { _wp = group _unit addWaypoint[ T1 modelToWorldVisual _startPos, 0 ]; _wp setWaypointType "CYCLE"; }; }forEach _savedPositions; ...where [0,0,0] and //... are replaced with as many positions as you noted down, and _unit is a reference to the unit to place/waypoint. Think that works out right, untested. I got the coordinates part working as you described but as for the part where you say "Then in your missions code after you have moved the tower, run..." do you mean this gets placed in the initPlayerLocal file? Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 28, 2020 11 hours ago, JohnKalo said: The sleep command cannot work in triggers. It works only in scripts. Yes the 1 means wait 1 second before continuing the script. NameofUnit setDir 45; // will set unit1 to face North-East Also if the waypoints dont work cause .... Arma 3 .... maybe this will help: NameOfUnit doMove (getPosATL NameOfObject1); If the ai is at the top of the tower all he does is walk to the bottom of it using this NameOfUnit doMove (getPosATL NameOfObject1); Share this post Link to post Share on other sites
Joe98 92 Posted November 28, 2020 Another option. You said you want the tower to start at a place at random. You could place 50 towers on the map and each one has a soldier on top. The soldier has waypoints so that he patrols around the top of the tower. Each of the 50 towers has a name: T0 to T49 Now have the game select a number at random from 0 - 49. That tower is kept and all the other towers are deleted. . Share this post Link to post Share on other sites
Joe98 92 Posted November 28, 2020 23 hours ago, BlackbirdSD said: What is a "bern"? Oops! I meant H-Barrier Share this post Link to post Share on other sites
froggyluv 2136 Posted November 28, 2020 27 minutes ago, BlackbirdSD said: If the ai is at the top of the tower all he does is walk to the bottom of it using this NameOfUnit doMove (getPosATL NameOfObject1); Just browsing through here but generally your not gonna get an AI to move somewhere specific in a complicated building unless the designer filled it with pathing nodes luck to yas 1 Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 28, 2020 27 minutes ago, Joe98 said: Another option. You said you want the tower to start at a place at random. You could place 50 towers on the map and each one has a soldier on top. The soldier has waypoints so that he patrols around the top of the tower. Each of the 50 towers has a name: T0 to T49 Now have the game select a number at random from 0 - 49. That tower is kept and all the other towers are deleted. . I got the random tower placement working fine using random start position Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 28, 2020 1 minute ago, froggyluv said: Just browsing through here but generally your not gonna get an AI to move somewhere specific in a complicated building unless the designer filled it with pathing nodes luck to yas I kind of thought so. Might be more trouble than its worth. Share this post Link to post Share on other sites
Larrow 2822 Posted November 28, 2020 After testing for a bit it, this seems to work ok... Spoiler //initServer.sqf //Spawn a scheduler thread to look after the patrol h = [] spawn { //Make sure the tower has moved waitUntil{ time > 2 }; //Building positions to patrol _savedPositions = [ 17, 15, 12, 10, 12, 15 ]; //Create unit at starting building pos _startPos = _savedPositions select 0; _unit = createGroup west createUnit[ "B_Soldier_F", ( T1 buildingPos _startPos ), [], 0, "FORM" ]; //While the unit is alive while { alive _unit } do { //Patrol building positions { _unit doMove ( T1 buildingPos _x ); waitUntil{ !alive _unit || { _unit distance ( T1 buildingPos _x ) <= 1 || unitReady _unit } }; if ( !alive _unit ) exitWith {}; }forEach _savedPositions; }; }; TEST_MISSION What is strange is that I have had to make the patrol ping-pong around the building positions (building position 17, 15 ,12, 10 and then back again 10, 12 ,15, 17). When ever I tried to make the patrol pass the door (move from building position 10 to 17 ) he would automatically open the door and proceed to the base of the tower. Extremely weird behaviour. 9 hours ago, froggyluv said: generally your not gonna get an AI to move somewhere specific in a complicated building unless the designer filled it with pathing nodes I generally agree, how ever most BI buildings do have pathing setup. Share this post Link to post Share on other sites
BlackbirdSD 15 Posted November 29, 2020 On 11/28/2020 at 4:42 AM, Larrow said: After testing for a bit it, this seems to work ok... Reveal hidden contents //initServer.sqf //Spawn a scheduler thread to look after the patrol h = [] spawn { //Make sure the tower has moved waitUntil{ time > 2 }; //Building positions to patrol _savedPositions = [ 17, 15, 12, 10, 12, 15 ]; //Create unit at starting building pos _startPos = _savedPositions select 0; _unit = createGroup west createUnit[ "B_Soldier_F", ( T1 buildingPos _startPos ), [], 0, "FORM" ]; //While the unit is alive while { alive _unit } do { //Patrol building positions { _unit doMove ( T1 buildingPos _x ); waitUntil{ !alive _unit || { _unit distance ( T1 buildingPos _x ) <= 1 || unitReady _unit } }; if ( !alive _unit ) exitWith {}; }forEach _savedPositions; }; }; TEST_MISSION What is strange is that I have had to make the patrol ping-pong around the building positions (building position 17, 15 ,12, 10 and then back again 10, 12 ,15, 17). When ever I tried to make the patrol pass the door (move from building position 10 to 17 ) he would automatically open the door and proceed to the base of the tower. Extremely weird behaviour. I generally agree, how ever most BI buildings do have pathing setup. Thank you very much for taking the time for this. I think this will be very helpful but I need to take some time to make sense of some of it. Share this post Link to post Share on other sites