OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: DurbanPoison on 11 Jun 2011, 23:45:49
-
hi there,
I did a search but couldn't find the specific thing im looking for so am gonna ask for help :P
I have a 1v1 mission where each player tries to reach the other side and touch a flag to win a point.
I have randomly added a few animations when one player reaches the flag and scores.. ie. he'll do a handstand.
When this anim happens the other player claps his hands above his head... only problem is he is ususally facing a different direction! so is there anyway to have a player controlled unit turn and face the other player?
i am noobish with script so tried dowatch and setdir but these don't seem to do what im trying to do!
any ideas? and thanks :)
-
Are these units AI, or is this part of a cutscene?
I know how to do it for AI, but apart from that. I am not to sure to be honest.
-
Yes, it's part of a brief cut scene that plays each time someone scores
-
What part of setdir doesn't work, it will set a player in the direction you choose or do you mean it looks bad as it's done instantly?
-
you can use SetDir, remember to blank out while you set them or have camera slowoly move in from away ,
setDir soldier 1 too so you can calculate where soldier 2 needs to face for example if soldier 1 is facing 90 then soldier 2 needs to face 270 so there staring at eachother .
-
There are a couple ways you can accomplish this:
turningUnit reveal targetUnit; turningUnit doWatch targetUnit; turningUnit lookAt targetUnitIf you can measure the angle that the unit has to turn through in order to be directly facing the target unit, you can do a setDir loop so that the turning is smooth. You will have to disable the "MOVE" part of the AI as in Arma 2 they will go back to where they were originally facing after using setDir. So, you can do something like this if the angle is 45 degrees:
turningUnit disableAI "MOVE";
_startDir = getDir turningUnit;
_endDir = 0;
while {_endDir != 45} do {
_endDir = _endDir + 1;
turningUnit setDir (_startDir + _endDir);
sleep 0.05;
};That will turn him 45 degrees smoothly to the right. Change it to (_startDir - _endDir) to turn him to the left. Increase the delay and decrease the amount _endDir increases by to make it slower. Hope that helps!