Jump to content
Sign in to follow this  
DirtyDel

Character / Object Random start height

Recommended Posts

I'm attempting to use markers to have an object in one mission (and a character in another mission) randomly spawn at marker positions using the "set random start" function. However, I can't edit the height of the markers (currently using empty markers). For example, a laptop or HVT spawning in a multiple story building. I searched the forum and found some marker array stuff, which I could not get to work. I'm seeking guidance from the blessed ARMA elders.

Share this post


Link to post
Share on other sites

Don't use markers. Use a small object placed where you want the item/unit to spawn. Set the object to hidden and simulation disabled.

 

Or a trigger, or a game logic.

Share this post


Link to post
Share on other sites
3 hours ago, Harzach said:

Don't use markers. Use a small object placed where you want the item/unit to spawn. Set the object to hidden and simulation disabled.

 

Or a trigger, or a game logic.

the "set random start" function only works with markers. Can you provide an example so I can explore this option?

Share this post


Link to post
Share on other sites

Put all of your position objects in an array, select one randomly, then setPos your object/unit.

 

An abstraction:

_posArray = [obj1, obj2, obj3, obj4, obj5];
_posObj = selectRandom _posArray;
_pos = getPosATL _posObj;
MyHVTUnit setPosATL _pos;

 

  • Like 1

Share this post


Link to post
Share on other sites
32 minutes ago, Harzach said:

Put all of your position objects in an array, select one randomly, then setPos your object/unit.

 

An abstraction:


_posArray = [obj1, obj2, obj3, obj4, obj5];
_posObj = selectRandom _posArray;
_pos = getPosATL _posObj;
MyHVTUnit setPosATL _pos;

 

Works absolutely fine with character model, but I'm getting global error (local variable in global space) for an object (laptop)

Share this post


Link to post
Share on other sites

The type of vehicle should make absolutely no difference.  How and where are you executing your code?

 

Share this post


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

The type of vehicle should make absolutely no difference.  How and where are you executing your code?

 

In the HVT mission, I have 5 small objects (hidden/ no simulation) labeled as obj1-obj5. The script you provided is in the characters' init. The HVT spawns randomly at all 5 locations.

 

In the laptop mission, I did the same, and placed the script in the laptops init, which prompts the "local variable in global space" error

Share this post


Link to post
Share on other sites

Again, what I posted was just an abstraction. If you are using it verbatim in a vehicle init, then you'll want to wrap it in a spawn or call.

nul = [] spawn {
	_posArray = [obj1, obj2, obj3, obj4, obj5];
	_posObj = selectRandom _posArray;
	_pos = getPosATL _posObj;
	MyHVTUnit setPosATL _pos;
};

 

  • Like 1

Share this post


Link to post
Share on other sites

For this I use something very small like a small stone.

Place 20 of them on the map and set the height for each one.

 

Each stone has a name:

stone0

stone1.....

stone19

 

You are named  blue1
 

The code is     blue1  setpos   getpos   stone0     and you will start on stone0

 

Instead of using  0  you  select a number at random  (sorry not at home at present)  

 

I think Harzach's solution above is another way although I have not tried it.

 

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
11 hours ago, Harzach said:

Again, what I posted was just an abstraction. If you are using it verbatim in a vehicle init, then you'll want to wrap it in a spawn or call.


nul = [] spawn {
	_posArray = [obj1, obj2, obj3, obj4, obj5];
	_posObj = selectRandom _posArray;
	_pos = getPosATL _posObj;
	MyHVTUnit setPosATL _pos;
};

 

I was so close to achieving that on my own. I missed the brackets after =.

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  

×