Jump to content
kvntvan

setting object to terrain height

Recommended Posts

Hello, I'm using a script to give my players an addaction that builds a small camp, however I'm having trouble with the objects spawning in the ground instead of at terrain height.

9320307d9a.jpg

I figured out how to make it conform to the terrains slope yet have not been able to figure out how to spawn it matching the terrains height. I've used several combinations of several commands like setposatl/getposatl/getterrainheightasl/setposworld/getposworld etc etc but have failed to produce anything that works.

 

private["_objType","_objName","_unit","_unitName","_unitDir","_unitPos","_spawnTime","_spawnDistance","_action"];
_unit = _this select 0;
_action = _this select 2;
_unit removeAction _action;



_objType = "Land_TentA_F";



_unitName = name _unit;
_unitDir = direction _unit;
_unitPos = position _unit;



//Wait time till object is spawned, set 0 for instant
_spawnTime = 5;


_spawnDist = 6;


obj1 = _objType createVehicle [0,0,0];

_unit playMove "AinvPknlMstpSnonWnonDnon_medicUp3";


sleep _spawnTime;
obj1 setpos (_unit modelToWorld [0,_SpawnDist,0]);
obj1 setdir (getdir player);
obj1 setPosATL (getPosATL obj1);
camp1 = obj1 addAction ["<t color=""#F8FF24"">" +format["Pack Up Camp"],"Camp_Script\pack.sqf"];

Theres part of the code I'm using, it all works perfectly until that second to last line where I try to set the object to terrain height. Does anyone know the proper scripting command I should be using to pull this off?

Share this post


Link to post
Share on other sites

Click on the item and drag the item up or down.

 

OR:  Click on the item and note the properties. An item is placed in 3 dimensions:   North-South    East-West   Up-Down.  Change the number in the Up-Down  dimension.

 

Share this post


Link to post
Share on other sites

Maybe try replacing this:

obj1 setpos (_unit modelToWorld [0,_SpawnDist,0]);
obj1 setdir (getdir player);
obj1 setPosATL (getPosATL obj1);

With this:

obj1 setDir getDir player;
obj1 setPos (player getRelPos [_SpawnDist,0]);

 

Share this post


Link to post
Share on other sites

obj1 = _objType createVehicle [0,0,0];

 _unit playMove "AinvPknlMstpSnonWnonDnon_medicUp3";
 
sleep _spawnTime;
obj1 setpos (_unit getpos [_SpawnDist,getdir player]);
obj1 setVehiclePosition [getpos obj1,[],0,"none"];
obj1 setdir getdir player;
obj1 setVectorUp surfaceNormal getpos obj1;

 

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

obj1 = _objType createVehicle [0,0,0];

 _unit playMove "AinvPknlMstpSnonWnonDnon_medicUp3";
 
sleep _spawnTime;
obj1 setpos (_unit getpos [_SpawnDist,getdir player]);
obj1 setVehiclePosition [getpos obj1,[],0,"none"];
obj1 setdir getdir player;
obj1 setVectorUp surfaceNormal getpos obj1;

 

 

thank you!

 

obj1 setVehiclePosition [getpos obj1,[],0,"none"];

did the trick but i had to change none to "Can_Collide"

  • Like 1

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

×