- Home /
Player position after application.LoadLevel
i have tried a few ways of setting the position of the player after application.load level but i cant seem to get it to work, any ideas on how to solve this?
thanks
It would probably help if you let us know what you have already tried unless you'd like us to suggest the same thing.. so what have you tried and what results did you get?
Well why don't you set the player's position at the start of the scene you are loading?
@ryisnelly PLEASE TIC$$anonymous$$ AN ANSWER, THAN$$anonymous$$S, TO $$anonymous$$EEP THE BOARD TIDY.
@ryisnelly PLEASE TIC$$anonymous$$ AN ANSWER, THAN$$anonymous$$S, TO $$anonymous$$EEP THE BOARD TIDY.
Answer by Fattie · Aug 26, 2013 at 12:27 PM
Simply ...
are you familiar with using the Awake() and Start() functions in Unity??
Try this. Have a marker object in your scene -- I mean, very simply, an empty game object.
In other words, just click on "Game Object" menu then "Create empty...".
Name this new "marker" object to be "MyHappyStartPosition"
Now, make a new script attached to your player car, dragon, warlord or whatever she is.
In the script, just say this:
var myStartPosition:Vector3;
myStartPosition =
GameObject.Find("MyHappyStartPosition").transform.position;
transform.position = myStartPosition;
that's it. You can do that in the Start() function.
Now when you are using the editor, just MOVE AROUND the marker object, MyHappyStartPosition, however you want.
Click Play, and you'll see the dragon/warlord/whatever begins the game in that position.
It's important to use "marker objects" all the time in Unity development.
Hope it helps!
Just BTW. if you simply sit the character, where you want it, it will be there in that position when the game Plays! :) But I assume you are building it or something, and hence, need to do what I describe here for your greatest convenience.
Your answer
Follow this Question
Related Questions
Click Object to change scene 2 Answers
Load Level in background and load it when key is pressed 2 Answers
Levels, stages, scenes 0 Answers
Application.LoadLevel strange problem 2 Answers