Jump to content
braker

[SOLVED] How to store rotation x, y and z of an object in variable?

Recommended Posts

Hello, I would like to store the rotation params' of an object in order to reuse it later.

 

How I can do that?

 

Thanks and regards.

Share this post


Link to post
Share on other sites

vectorUphttps://community.bistudio.com/wiki/vectorUp
vectorDirhttps://community.bistudio.com/wiki/vectorDir

 

+their Counterpart:

setVectorUphttps://community.bistudio.com/wiki/setVectorUp

setVectorDirhttps://community.bistudio.com/wiki/setVectorDir

 

or both together (you might have to use that, when you want to set Dir and Up):
setVectorDirAndUp - https://community.bistudio.com/wiki/setVectorDirAndUp

 

Also: Fav that page ;)
https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3

 

Share this post


Link to post
Share on other sites

You can store them as a variable on the object for use later:

 

_thing setVariable ["rotParams",[vectorDir _thing,vectorUp _thing]];

 

// then retrieve later on

 

_vects = _thing getVariable ["rotParams",[[0,1,0],[0,0,1]]];

 

Share this post


Link to post
Share on other sites

Thanks for replies.

 

But my object is attached to anotherone and when I try to setVectorDirAnd up, the coordinates are "converted" in object relative.

 

So my new question: how to setVectorDirAndUp of an attached object using world coordinates instead of relative to object ones?

Share this post


Link to post
Share on other sites

I think u have to detach, rotate and then attach it again.

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites
6 hours ago, sarogahtyp said:

I think u have to detach, rotate and then attach it again.

sent from mobile using Tapatalk
 

 

Yes, but when I reattach the object, the vectorDirAndUp values are reset...

Share this post


Link to post
Share on other sites

Maybe you should show some code. Last time I did this was long ago in arma 2 and these methods should​ not have changed much I think. At this time I tried to tweak something what is slingload today and I don't remember that the vectors were reset.

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites
1 minute ago, sarogahtyp said:

Maybe you should show some code. Last time I did this was long ago in arma 2 and these methods should not have changed much I think. At this time I tried to tweak something what is slingload today and I don't remember that the vectors were reset.

sent from mobile using Tapatalk
 

 

I will post an example of .SQM in 20 minutes.

Share this post


Link to post
Share on other sites

Here is the SQM file:

 

version=53;
class EditorData
{
	moveGridStep=1;
	angleGridStep=0.2617994;
	scaleGridStep=1;
	autoGroupingDist=10;
	toggles=1;
	class ItemIDProvider
	{
		nextID=7;
	};
	class Camera
	{
		pos[]={22435.078,36.603054,19374.434};
		dir[]={0.74071795,-0.47827306,-0.47202227};
		up[]={0.40337974,0.87813753,-0.25704998};
		aside[]={-0.53747457,-1.1497177e-006,-0.84342486};
	};
};
binarizationWanted=0;
addons[]=
{
	"A3_Soft_F_Gamma_Van_01",
	"A3_Weapons_F_Explosives",
	"A3_Modules_F_Curator_Mines",
	"A3_Characters_F"
};
class AddonsMetaData
{
	class List
	{
		items=4;
		class Item0
		{
			className="A3_Soft_F_Gamma";
			name="Arma 3 - Unarmored Land Vehicles";
			author="Bohemia Interactive";
			url="https://www.arma3.com";
		};
		class Item1
		{
			className="A3_Weapons_F";
			name="Arma 3 Alpha - Weapons and Accessories";
			author="Bohemia Interactive";
			url="https://www.arma3.com";
		};
		class Item2
		{
			className="A3_Modules_F_Curator";
			name="Arma 3 Zeus Update - Scripted Modules";
			author="Bohemia Interactive";
			url="https://www.arma3.com";
		};
		class Item3
		{
			className="A3_Characters_F";
			name="Arma 3 Alpha - Characters and Clothing";
			author="Bohemia Interactive";
			url="https://www.arma3.com";
		};
	};
};
randomSeed=8773610;
class ScenarioData
{
	author="Braker";
};
class Mission
{
	class Intel
	{
		timeOfChanges=1800.0002;
		startWeather=0.30000001;
		startWind=0.1;
		startWaves=0.1;
		forecastWeather=0.30000001;
		forecastWind=0.1;
		forecastWaves=0.1;
		forecastLightnings=0.1;
		rainForced=1;
		lightningsForced=1;
		wavesForced=1;
		windForced=1;
		year=2035;
		month=6;
		day=24;
		hour=12;
		minute=0;
		startFogDecay=0.014;
		forecastFogDecay=0.014;
	};
	class Entities
	{
		items=3;
		class Item0
		{
			dataType="Object";
			class PositionInfo
			{
				position[]={22439.697,35.13797,19371.984};
				angles[]={5.9270477,5.3319769,6.13234};
			};
			side="Empty";
			flags=4;
			class Attributes
			{
				name="truck";
			};
			id=1;
			type="O_G_Van_01_transport_F";
			atlOffset=-0.15500641;
			class CustomAttributes
			{
				class Attribute0
				{
					property="ammoBox";
					expression="[_this,_value] call bis_fnc_initAmmoBox;";
					class Value
					{
						class data
						{
							class type
							{
								type[]=
								{
									"STRING"
								};
							};
							value="[[[[""FirstAidKit""],[2]],[[],[]],[[],[]],[[],[]]],false]";
						};
					};
				};
				nAttributes=1;
			};
		};
		class Item1
		{
			dataType="Object";
			class PositionInfo
			{
				position[]={22438.188,35.549477,19372.959};
				angles[]={0.012765876,2.2236679,0.35820588};
			};
			side="Empty";
			class Attributes
			{
				init="call{chargePos = truck worldToModel getPos this; this attachTo [truck, chargePos];}";
			};
			id=3;
			type="DemoCharge_F";
			atlOffset=1.676506;
		};
		class Item2
		{
			dataType="Group";
			side="West";
			class Entities
			{
				items=1;
				class Item0
				{
					dataType="Object";
					class PositionInfo
					{
						position[]={22436.998,30.648943,19363.871};
						angles[]={5.9270477,0.27094686,6.13234};
					};
					side="West";
					flags=6;
					class Attributes
					{
						isPlayer=1;
					};
					id=6;
					type="B_soldier_UAV_F";
					class CustomAttributes
					{
						class Attribute0
						{
							property="acex_headless_blacklist";
							expression="_this setVariable [""acex_headless_blacklist"",_value,true]";
							class Value
							{
								class data
								{
									class type
									{
										type[]=
										{
											"BOOL"
										};
									};
									value=0;
								};
							};
						};
						class Attribute1
						{
							property="speaker";
							expression="_this setspeaker _value;";
							class Value
							{
								class data
								{
									class type
									{
										type[]=
										{
											"STRING"
										};
									};
									value="Male12ENG";
								};
							};
						};
						class Attribute2
						{
							property="pitch";
							expression="_this setpitch _value;";
							class Value
							{
								class data
								{
									class type
									{
										type[]=
										{
											"SCALAR"
										};
									};
									value=1.01;
								};
							};
						};
						nAttributes=3;
					};
				};
			};
			class Attributes
			{
			};
			id=4;
		};
	};
};

Youc can see in this scenario that the rotation of the explosive charge in the 3D editor, doesn't match with the rotation of this charge when you play the scenario. Because the "attachTo" command reset the vectorDirAndUp of the attached object.

Share this post


Link to post
Share on other sites
8 hours ago, killzone_kid said:

 

Thanks for your reply. For some reason I missed/forgot this function.

 

The problem is now solved by entering this line in the init field of the charge:

chargeVectorDirAndUp = [this, truck] call BIS_fnc_vectorDirAndUpRelative; this attachTo [truck, truck worldToModel getPos this]; this setVectorDirAndUp chargeVectorDirAndUp;

Or more simply:

[this, truck] call BIS_fnc_attachToRelative;

 

Share this post


Link to post
Share on other sites

You should check if "this" is local, you dont want the code executed for every JIP

 

Share this post


Link to post
Share on other sites
4 hours ago, killzone_kid said:

You should check if "this" is local, you dont want the code executed for every JIP

 

 

What do you mean by "JIP"?

 

EDIT: Join In Progress?

If a player join the multiplayer game the init field of objects is reexecuted?

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

×