- Home /
create an object at loadlevel
so i have this script that creates a player after starting a level but the player dosnt work i dont think anything in the player is working. the player has a rigidbody and when he is created hes just standing in the air and dosnt fall. is there a way to get the player to work.
static var one: boolean = false; var characterone:Transform;
function Update () { if(one) {
Application.LoadLevel(1); var player= Instantiate(characterone, GameObject.Find("startpoint").transform.position, Quaternion.identity); }
}
Answer by Borgo · Jan 13, 2011 at 05:34 PM
you don't need to instantiate a object, just put it in the scene, wherever you want.
What Borgo means, to go on it, is, you dont instantiate the player, you just drag the player in the scene, and it automatically does everything, so put the character in the scene, and then start the scene, it'll work.
Thanks, I edited my answers, my english is not very good. :)
no u see that will not work because in the first level u can select what character u want to play as then the second level starts with the player that u have selected, thats my game. but its not working i can select the player move on to the next level but then the character doesn't work
Answer by DaveA · Jan 13, 2011 at 08:34 PM
Not sure on this, but LoadLevel will load the level, right? And start scripts in THAT level. So why not have a Start or Awake function in the next level instantiate your player? If you need to port variables (like 'player preference') from scene to scene, the easiest way is PlayerPrefs http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
Your answer
Follow this Question
Related Questions
help loading level after destroying objects 1 Answer
Next LEVEL Load Problem. 2 Answers
Tagged Load level 1 Answer
Two player collision ? 1 Answer
Death scene/screen on player Health Script Wont work! 0 Answers