Jump to content
Sign in to follow this  
A Man

Setting up unit view direction

Recommended Posts

Is there a way to setup the direction in that the unit looks when it spawns? My DZMS units have a static spawn so they dont move. How can I setup up different direction in that each unit can look? My problem is not to get the amount of the direction it is how can I det to a specific unit. I tired that in the DZMSAISpawn.sqf  

_unit setDir _dir;

 

Share this post


Link to post
Share on other sites
13 minutes ago, A Man said:

Is there a way to setup the direction in that the unit looks when it spawns? My DZMS units have a static spawn so they dont move. How can I setup up different direction in that each unit can look? My problem is not to get the amount of the direction it is how can I det to a specific unit. I tired that in the DZMSAISpawn.sqf  

_unit setDir _dir;

 

mm dont know if is that you looking for ..but for example :

 

_dir = ["-54.676876"];  (not sure about the "" in the sintax )

_this setDir _dir;

 

Share this post


Link to post
Share on other sites

Example:

_vehicle_9 = objNull;
if (true) then
{
  _this = createVehicle ["LADAWreck", [4069.2961, 11685.608, -0.00012207031], [], 0, "CAN_COLLIDE"];
  _vehicle_9 = _this;
  _this setDir 118.717;
  _this setPos [4069.2961, 11685.608, -0.00012207031];
};

Share this post


Link to post
Share on other sites

@Tech_Support  he wanna use setDir on it:

Spoiler

/*                                                                        //
    DZMSAISpawn.sqf by Vampire
    Usage: [position,unitcount,skillLevel] execVM "dir\DZMSAISpawn.sqf";
        Position is the coordinates to spawn at [X,Y,Z]
        UnitCount is the number of units to spawn
        SkillLevel is the skill number defined in DZMSAIConfig.sqf
*/                                                                        //
private ["_position","_unitcount","_skill","_wpRadius","_xpos","_ypos","_unitGroup","_aiskin","_unit","_weapon","_magazine","_wppos1","_wppos2","_wppos3","_wppos4","_wp1","_wp2","_wp3","_wp4","_wpfin","_unitArrayName","_unitMissionCount"];
_position = _this select 0;
_unitcount = _this select 1;
_skill = _this select 2;
_unitArrayName = _this select 3;

//diag_log text format ["[DZMS]: AI Pos:%1 / AI UnitNum: %2 / AI SkillLev:%3",_position,_unitcount,_skill];

_wpRadius = 20;

_xpos = _position select 0;
_ypos = _position select 1;

//Create the unit group. We use east by default.
_unitGroup = createGroup east;

//Probably unnecessary, but prevents client AI stacking
if (!isServer) exitWith {};

for "_x" from 1 to _unitcount do {

    //Lets pick a skin from the array
    _aiskin = DZMSBanditSkins call BIS_fnc_selectRandom;
    
    //Lets spawn the unit
    _unit = _unitGroup createUnit [_aiskin, [(_position select 0),(_position select 1),(_position select 2)], [], 10, "PRIVATE"];
    
    //Make him join the correct team
    [_unit] joinSilent _unitGroup;
    
    //Add the behaviour
    _unit enableAI "TARGET";
    _unit enableAI "AUTOTARGET";
    _unit enableAI "MOVE";
    _unit enableAI "ANIM";
    _unit enableAI "FSM";
    _unit setCombatMode "YELLOW";
    _unit setBehaviour "COMBAT";
    
    //Remove the items he spawns with by default
    removeAllWeapons _unit;
    removeAllItems _unit;
    
    //Now we need to figure out their loadout, and assign it
    
    //Get the weapon array based on skill
    _weaponArray = [_skill] call DZMSGetWeapon;
    
    _weapon = _weaponArray select 0;
    _magazine = _weaponArray select 1;
    
    //diag_log text format ["[DZMS]: AI Weapon:%1 / AI Magazine:%2",_weapon,_magazine];
    
    //Get the gear array
    _aigearArray = [DZMSGear0,DZMSGear1,DZMSGear2,DZMSGear3,DZMSGear4];
    _aigear = _aigearArray call BIS_fnc_selectRandom;
    _gearmagazines = _aigear select 0;
    _geartools = _aigear select 1;
    
    //Gear the AI backpack
    _aipack = DZMSPacklist call BIS_fnc_selectRandom;

    //Lets add it to the Unit
    for "_i" from 1 to 3 do {
        _unit addMagazine _magazine;
    };
    _unit addWeapon _weapon;
    _unit selectWeapon _weapon;
    
    _unit addBackpack _aipack;
    
    if (DZMSUseNVG) then {
        _unit addWeapon "NVGoggles";
    };
    
    {
        _unit addMagazine _x
    } forEach _gearmagazines;
    
    {
        _unit addWeapon _x
    } forEach _geartools;
    
    _aicskill = DZMSSkills1;
    
    //Lets set the skills
    switch (_skill) do {
        case 0: {_aicskill = DZMSSkills0;};
        case 1: {_aicskill = DZMSSkills1;};
        case 2: {_aicskill = DZMSSkills2;};
        case 3: {_aicskill = DZMSSkills3;};
    };
    
    {
        _unit setSkill [(_x select 0),(_x select 1)]
    } forEach _aicskill;
    
    //Lets prepare the unit for cleanup
    _unit addEventHandler ["Killed",{ [(_this select 0), (_this select 1)] ExecVM DZMSAIKilled; }];
    _unit setVariable ["DZMSAI", true];
};

//Lets give a launcher if enabled
//The last _unit should still be defined from the FOR above
if (DZMSUseRPG) then {
    _unit addWeapon "RPG7V";
    _unit addMagazine "PG7V";
    _unit addMagazine "PG7V";
};

// These are 4 waypoints in a NorthSEW around the center
_wppos1 = [_xpos, _ypos+20, 0];
_wppos2 = [_xpos+20, _ypos, 0];
_wppos3 = [_xpos, _ypos-20, 0];
_wppos4 = [_xpos-20, _ypos, 0];

// We add the 4 waypoints
_wp1 = _unitGroup addWaypoint [_wppos1, _wpRadius];
_wp1 setWaypointType "MOVE";
_wp2 = _unitGroup addWaypoint [_wppos2, _wpRadius];
_wp2 setWaypointType "MOVE";
_wp3 = _unitGroup addWaypoint [_wppos3, _wpRadius];
_wp3 setWaypointType "MOVE";
_wp4 = _unitGroup addWaypoint [_wppos4, _wpRadius];
_wp4 setWaypointType "MOVE";

// Then we add a center waypoint that tells them to visit the rest
_wpfin = _unitGroup addWaypoint [[_xpos,_ypos, 0], _wpRadius];
_wpfin setWaypointType "CYCLE";

//diag_log text format ["[DZMS]: Spawned %1 AI at %2",_unitcount,_position];

// load the unit groups into a passed array name so they can be cleaned up later
call compile format["
%1 = %1 + (units _unitGroup);
_unitMissionCount = count %1;
",_unitArrayName];

diag_log text format["[DZMS]: (%3) %1 AI Spawned, %2 units in mission.",count (units _unitGroup),_unitMissionCount,_unitArrayName];

 

maybe you can help him better than me

Share this post


Link to post
Share on other sites

Try

_unit setDir 118.717;

something like
    //Add the behaviour
    _unit enableAI "TARGET";
    _unit enableAI "AUTOTARGET";
    _unit enableAI "MOVE";
    _unit enableAI "ANIM";
    _unit enableAI "FSM";
    _unit setCombatMode "YELLOW";
    _unit setBehaviour "COMBAT";
    _unit setDir 118.717;

 

Share this post


Link to post
Share on other sites

Dont those ai spawn and move to way points i thought he was trying to use this on static ai

not much point setting a direction if they are going to run off

// We add the 4 waypoints
_wp1 = _unitGroup addWaypoint [_wppos1, _wpRadius];
_wp1 setWaypointType "MOVE";
_wp2 = _unitGroup addWaypoint [_wppos2, _wpRadius];
_wp2 setWaypointType "MOVE";
_wp3 = _unitGroup addWaypoint [_wppos3, _wpRadius];
_wp3 setWaypointType "MOVE";
_wp4 = _unitGroup addWaypoint [_wppos4, _wpRadius];
_wp4 setWaypointType "MOVE";

// Then we add a center waypoint that tells them to visit the rest
_wpfin = _unitGroup addWaypoint [[_xpos,_ypos, 0], _wpRadius];
_wpfin setWaypointType "CYCLE";

Share this post


Link to post
Share on other sites

Something is wrong if your units do not move in missions in DZMS.. 

I installed it and the ai are fine.. They spawn in a group sometimes but after a few seconds start moving around.. 

If you use a admin tool and teleport to the missions sometimes the ai get stuck a little longer but they eventually start roaming around the mission :) 

Share this post


Link to post
Share on other sites

Ok guys, a few explanation.

In my DZMS spawn, only spawns one unit not 2 or 3  on one spawn and i removed the move waypoint and replaced it. The behavior is fine. They spawn and stand on their location but all of them have the same view direction:

For better understanding the code of one of my missions:

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray, dir]
sleep 5;
[[8563.3066, 12158.677, 0.20555609],1,2,"DZMSUnitsMinor", -85] call DZMSAISpawnMilitarySmall;
sleep 5;
[[8561.7842, 12155.55, 0.20444736],1,2,"DZMSUnitsMinor",-9] call DZMSAISpawnMilitarySmall;
sleep 5;
[[8568.1836, 12162.761, 0.19326301],1,2,"DZMSUnitsMinor",-183] call DZMSAISpawnMilitarySmall;
sleep 5;
[[8568.0352, 12153, 0],1,2,"DZMSUnitsMinor",177] call DZMSAISpawnMilitarySmall; // behind out
sleep 5;
[[8562.0508, 12163, 0],1,2,"DZMSUnitsMinor",30] call DZMSAISpawnMilitarySmall;
sleep 5;

I already gave the AI a dir value and the value is used in the DZMSAISpawn.sqf

_position = _this select 0;
_unitcount = _this select 1;
_skill = _this select 2;
_unitArrayName = _this select 3;
_dir = _this select 4;

It works good to this point. The value is right.

We have now that code:

for "_x" from 1 to _unitcount do {

	//Lets pick a skin from the array
	_aiskin = DZMSMilitarySkins call BIS_fnc_selectRandom;
	
	//Lets spawn the unit
	_unit = _unitGroup createUnit [_aiskin, [(_position select 0),(_position select 1),(_position select 2)], [],  0, "CAN_COLLIDE"];
	//_unit setDir _dir; (that does not work)
	
	//Make him join the correct team
	[_unit] joinSilent _unitGroup;
	
	//Add the behaviour
	_unit enableAI "TARGET";
	_unit enableAI "AUTOTARGET";
	_unit enableAI "MOVE";
	_unit enableAI "ANIM";
	_unit enableAI "FSM";
	_unit setCombatMode "RED";
	_unit setBehaviour "AWARE";

I dont get the value on the AIs. _unit setDir 180; or another value does not work too. So the command _unit setDir is not ony the right place or sometinh like that.

Share this post


Link to post
Share on other sites

Try change 12158.677 they should face a different Direction

[[8563.3066, 12158.677, 0.20555609]

X,Y,Z

https://community.bistudio.com/wiki/Position#PositionRelative

Positions in Arma could be either 2D, in which case it is in format [x,y], where x is the coordinate on the SouthNorth axis and y is the coordinate on WestEast axis, or 3D, in which case it is in format [x,y,z], where z is the height. The height relative to exactly what differs depending on the format of 3D position used.

Share this post


Link to post
Share on other sites

After a while I noticed that setDir is working. The unit spawns in the determined direction, but than the unit turns around still in the spawn process and turns to setDir 0;  I removed every waypoint and other stuff but I dont no why.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...