- Home /
Player Attribute Script
Hello!
emm, first i don't know if my Question is right, but just tell me if i'm wrong, i'll correct it.. :D
emm, so basically, i confused how to create Player Attribute Script..
For starting, i have a char selection scene, so i can select to play as a Girl or Boy..
and in every of my scene inside the game, i create 2 prefab which is Girl and Boy, but from the char_selection scene, i flag the selection so in every scene, it will read the selection, and destroy the unselected prefab.. and move the selected to place i want..
for example, i choose Girl, then i move to game_Scene, there's 2 prefab there from the start.. but because i choose Girl, i destroy the Boy and move the Girl to the center.. the problem is..
i confused, where to place the player attribute? i mean if i place it on the prefab, will the attribute saved for the next scene (like hp, exp, level)? or it will renew because i load new prefab?
should i place the script in every prefab (i mean on the Boy and Girl)?
Thanks before :)
Answer by Kumo-Kairo · Jan 04, 2014 at 11:20 AM
I think you should just store player's choice in a variable inside a non-destructible object (empty game object will do with DontDestroyOnLoad() ) and the models will be just dummies. Therefore, there will be just one script on one object. When your scene starts, just use something like FindWithTag or Find inside your Player object to reference that stats object and you're good to go.
emm, yeah i store the player's choice in a variable.. it's on the char_selection scene..
and every scene after that, i create a script, which is charSpawn, and find that variable on others script and take it as a flag..
so, u say there will only be 1 script on 1 object, u mean the player attribute script on empty game object?
sorry still dont quite understand.. :)
Your answer
Follow this Question
Related Questions
Detect face of cube clicked 4 Answers
Camera to follow the mouse to move to create the point 0 Answers
Prefab Instancing 2 Answers
Accessing function from another script won't work 1 Answer
Unity Account system 1 Answer