Jump to content
Sign in to follow this  
racercowan

Making object start a mission in a random discrete location

Recommended Posts

I am making a mission where I want an item to be located in one of a few distinct location.

 

My approach to trying to do this was to have a variable choose a random value during init and then using that variable in the object's Condition of Presence. Specifically, something like RNG_A = selectRandom [1,2,3] in the mission init and then RNG_A == 1 in the Conditions of Presence on an object. This seems ineffective however, as none of the objects spawn. Based on a bit of googling, it seems that the issue could be that apparently the mission init happens after all of the objects?

 

Is there a better way to make an object appear in a random pre-defined location? Is there somewhere I could define the variable before objects are evaluated, or do I need to copy down each of the possible positions and rotations and stick it in a trigger somewhere?

Share this post


Link to post
Share on other sites

You could place markers at each desired location, and one object wherever. Then something along the lines of:

_mrk = selectRandom ["marker1","marker2","marker3","marker4","marker5"];
_pos = getMarkerPos _mrk;
objectname setPos _pos;

 

  • Like 1

Share this post


Link to post
Share on other sites

Markers don't have heights or rotations right, just XY coordinates?

 

Could a similar trick be used by taking the position and rotations of some dummy placeholder and moving the object to them (and then delete all the dummies obviously).

Share this post


Link to post
Share on other sites
18 minutes ago, Gunter Severloh said:

I have a video on this, lol

 

 

This does seem helpful, but the issue with markers is that they don't have height or facings, where as I'm trying to place things on tables and shelves.

 

Also, can props be grouped like units can? I've seen multiple things mentioning grouped items, but so far as I can tell you can at most save a composition or place them into a folder. I'd be moving two items in tandem, so if they aren't grouped together then would is there an order to the init of individual objects, or can I freely define a global variable in one object's init to be used by any other object's init.

Share this post


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

Markers don't have heights or rotations right, just XY coordinates?

 

See alternate syntax: https://community.bistudio.com/wiki/getMarkerPos

 

1 hour ago, racercowan said:

some dummy placeholder

 

Use a game logic. Or whatever object you fancy. Use something that is non-interactable, does not have physics, and set hideObject to true, and you can just leave it.

Share this post


Link to post
Share on other sites
44 minutes ago, racercowan said:

but the issue with markers is that they don't have height or facings

 

Height addressed above. Markers have rotation. Retrieve it with markerDir.

  • Thanks 1

Share this post


Link to post
Share on other sites

In the end I decided to have the multiple duplicate objects and using a trigger that deletes the "wrong" objects.

Share this post


Link to post
Share on other sites

Click on the marker. It has X,Y and z coordinates.

Share this post


Link to post
Share on other sites

I can see an X, Y, and rotation for markers. getMarkerPos says it can return a height AGL, but I don't see a way to set a height in the editor. How is the AGL height of a marker determined?

 

Share this post


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

How is the AGL height of a marker determined?

 

setMarkerPos

"markerName" setMarkerPos [(getMarkerPos "markerName" # 0),(getMarkerPos "markerName" # 1), 5];

//  sets "markerName" height to 5 meters

If you want to do it all in the editor, then you might be better off using game logics or "dumb" objects.

  • Thanks 1

Share this post


Link to post
Share on other sites

An example using a "dumb" object.

 

Find something small such as a watch.

 

Enter the map as a player and double check that you can actually place the item where you want to place it.

 

Go back to the editor and place the item at that location. If you wish to place it on a table then you have to move it around a bit to get it just right.

 

Enter the map as player and double check it is positioned correctly.

 

Back to the editor and get the x,y,z coordinates of the object.

 

Do this with 10 watches across the map and note their coordinates.

.

 

 

 

 

 

 

 

 

 

 

 

 

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  

×