• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rgalaxy · Jan 04, 2014 at 10:57 AM · javascriptplayer-settings

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 :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rgalaxy · Jan 04, 2014 at 11:44 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to optimize this script and add items imediately without grids 0 Answers

How to save data on iOS? 1 Answer

Spawn gameObjects at random locations in limited area 4 Answers

Restart this script 3 Answers

If the number is the same as script piece 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges