|
Hi!!! I want my player start on different locations everytime I start a new game? How do I do that? Just now my player is in the game at the same startplace! Thanks for help!!!!
(comments are locked)
|
|
One simple solution is to: 1) create several empty GameObjects, tag or name them as "spawnpoint" or something. 2) cache the transform of these GOs at the start of your game (via list, array, hashtable, etc) 3) randomly search through your array of spawnpoint transforms and use the resulting transform.position as your player's transform.position. All that within your Awake(). Simple Hint: You could create a SpawnPoint manager script for your player, attach that to a SpawnPointManager GameObject, and do all those simple steps there instead. That way, you'd be separating the spawning logic of your character from any other stuff you'd be doing.
(comments are locked)
|
|
I tried Bravinis idea but it does not work, somting is wrong with the code! It says at the second last line 14 - expcting ), found ;. Thankyou for awnser! Hope you will get back! or sombody know whats wrong? Thankyou!!!!! add a closing parenthesis to the last line like so: Instantiate( PlayerPrefab, transform.position(xpos,ypos,zpos), (transform.rotation(0,0,0)) ); By the way, commenting on the 'answer' is the proper way to reply hehe. rules are rules xD
Oct 20 '10 at 09:03 AM
zannghast
(comments are locked)
|
|
create a script with the code below and attach it to an object on the scene then delete your Player object. drag your Playerpreab on the inspector to the var PlayerPrefab.
sorry for the bad indentation, still new to this.
(comments are locked)
|
