Jump to content
Sign in to follow this  
aaronhance

need help with setDir

Recommended Posts

I'm trying to set the rotation of a vehicle to the rotation of a player. So far I have the below, but it does not work.

called via: setrot = _veh execVM "rot.sqf";

_veh = _this select 0;
_veh setDir getDir player; 
_veh setPos getPos _veh;

Share this post


Link to post
Share on other sites

_veh = _this select 0;
_degrees = getDir player;

_veh setDir _degrees;

call with

null = [this] execVM "rot.sqf"; if using it from the vehicles init

otherwise if from a trigger or a different script name the vehicle, then use e.g. null = [helo] execVM "rot.sqf" if the vehicle is named helo.

Edited by clydefrog

Share this post


Link to post
Share on other sites
_veh = _this select 0;
_degrees = getDir player;

_veh setDir _degrees;

call with

null = [this] execVM "rot.sqf"; if using it from the vehicles init

otherwise if from a trigger or a different script name the vehicle, then use e.g. null = [helo] execVM "rot.sqf" if the vehicle is named helo.

Nope, still does not work.

This is where it is called:

//place bargate script - by [bB]Aaron

if(side player == west)then{
if(bargateAmmount > 0)then{
	bargateAmmount = bargateAmmount - 1;
	_veh = "Land_BarGate_F" createVehicle (position player);
	null = _veh execVM "rot.sqf";
	removeBargate = _veh addAction ['Remove Bargate','rbg.sqf'];
}
else{
	hint "You have no bargates!";
};
};

Share this post


Link to post
Share on other sites
Nope, still does not work.

I've tested that before I posted it and it works, so I don't know how you're using it/what you're doing wrong.

Is _veh referring to the bargate then, or do you use _veh for another vehicle in that rot.sqf as well? Is that code meant to be setting the direction of the bargate to the direction the player is facing?

Edited by clydefrog

Share this post


Link to post
Share on other sites
I've tested that before I posted it and it works, so I don't know how you're using it/what you're doing wrong.

Is _veh referring to the bargate then, or do you use _veh for another vehicle in that rot.sqf as well? Is that code meant to be setting the direction of the bargate to the direction the player is facing?

yes, no, yes.

Share this post


Link to post
Share on other sites
yes, no, yes.

Your script doesn't work as it is even without the execVM line and gives undefined variable error, what should bargateAmmount be before it checks for its value?

---------- Post added at 13:09 ---------- Previous post was at 13:06 ----------

//place bargate script - by [bB]Aaron

private ["_veh","_degrees"];

_degrees = getDir player;

bargateAmmount = 5;



if (side player == west) then {

if (bargateAmmount > 0) then {

	bargateAmmount = bargateAmmount - 1;

               publicVariable "bargateAmmount";

	_veh = "Land_BarGate_F" createVehicle (position player);

	_veh setDir _degrees;

	removeBargate = _veh addAction ['Remove Bargate','rbg.sqf'];

} else {

	hint "You have no bargates!";
};
};

try that, as you probably already know you'd have the bargateAmmount = whatever in your init.sqf most likely.

edit:

You should also use CreateVehicle Array instead of the older one, so:

//place bargate script - by [bB]Aaron

private ["_veh","_degrees"];

_degrees = getDir player;




if (side player == west) then {

if (bargateAmmount > 0) then {

	bargateAmmount = bargateAmmount - 1;

	_veh = createVehicle ["Land_BarGate_F", position player, [], 0, "NONE"];

	_veh setDir _degrees;

	removeBargate = _veh addAction ['Remove Bargate','rbg.sqf'];

} else {

	hint "You have no bargates!";
};
};

and then e.g. bargateAmmount = 5; in your init.sqf

Edited by clydefrog

Share this post


Link to post
Share on other sites
Your script doesn't work as it is even without the execVM line and gives undefined variable error, what should bargateAmmount be before it checks for its value?

---------- Post added at 13:09 ---------- Previous post was at 13:06 ----------

//place bargate script - by [bB]Aaron

private ["_veh","_degrees"];

_degrees = getDir player;

bargateAmmount = 5;



if (side player == west) then {

if (bargateAmmount > 0) then {

	bargateAmmount = bargateAmmount - 1;

               publicVariable "bargateAmmount";

	_veh = "Land_BarGate_F" createVehicle (position player);

	_veh setDir _degrees;

	removeBargate = _veh addAction ['Remove Bargate','rbg.sqf'];

} else {

	hint "You have no bargates!";
};
};

try that, as you probably already know you'd have the bargateAmmount = whatever in your init.sqf most likely.

edit:

You should also use CreateVehicle Array instead of the older one, so:

//place bargate script - by [bB]Aaron

private ["_veh","_degrees"];

_degrees = getDir player;




if (side player == west) then {

if (bargateAmmount > 0) then {

	bargateAmmount = bargateAmmount - 1;

	_veh = createVehicle ["Land_BarGate_F", position player, [], 0, "NONE"];

	_veh setDir _degrees;

	removeBargate = _veh addAction ['Remove Bargate','rbg.sqf'];

} else {

	hint "You have no bargates!";
};
};

and then e.g. bargateAmmount = 5; in your init.sqf

Thanks a lot!

Share this post


Link to post
Share on other sites

can I just add - use "CAN_COLLIDE" instead of "NONE" as AI will just walk through the object. not sure if its applicable, but......:rthumb:

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  

×