Hello, I am fairly new to Udon and am making a map. to make the map a little more dynamic I would like to to to have a object be in a different pre-determined location every time the map is loaded up. is there a way to accomplish this with Udon?
You could make a List of all the pre determined spawn points and a int for the Random Number - use Random.Range in the Start Function to set the value of your int.
Use that int to determine which Spawnpoint should be used.
then, you could use a switch for said int - and in each case ( one for every spawn point ) set the transform.position of your Gameobject equal to the transform.position of the correct spawnpoint in the list.
There’s probably an easier way to do that aswell, but I’m also kinda new, so thats the best I could come up with ^^’
Thanks, i will try that
i got the get location and rotation from an empty to set to the object working, but i am unsure how to make a list
just make an array of game objects which will be your possible spawn points.
after that you can use
Random.Range(0,Array.Length()); to pick a random position.
Alternatively, if you’re going to recycle things, e.g pickups that change location every so often.
you could also just disable all the pickup game objects and randomly enable them (which gives you a little better performance boost if you’re spawning a lot of them at once. After all, unity doesn’t like creating and destroying large amounts of objects, so just turning them on and off is the better option)