A beginner needs help!

Hey guys,

I wanted to make spawn points for my Character, it has 2 locations I want to spawn. And I want to random that points on Awake() function.

Here’s the example.

randomSpawns.js

var moveObject : Transform;
function firstSpawn()
{
	moveObject.transform.position.x = 499.4388;
	moveObject.transform.position.y = 25.81049;
	moveObject.transform.position.z = 152.4788;
}
function secondSpawn()
{
	moveObject.transform.position.x = 701.7835;
	moveObject.transform.position.y = 25.81049;
	moveObject.transform.position.z = 308.7407;
}
function Awake()
{
	firstSpawn();
}

So I want sometimes it spawns on firstSpawn and sometimes on secondSpawn. Any suggestions/help? Thanks! :smile:

With an if or switch.

You can try using Array object and the same time Range solution.

Thanks for help guys, i tried this before but didnt get it working. I dont know to put the code together. If its not hard for you to put it together in code for me, if it is, I will Try to do it my own when come back ar home.

Thanks for your time.

Something like this in your awake

if(Math.round(Math.random()) == 0){
     SpawnOne()
}
else {
    SpawnTwo()
}

might do the trick.

It seems it will, i will give u a shot when i Try it. Thanks!