Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
This question was closed Jun 18, 2014 at 12:24 AM by T-D-M-3 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by T-D-M-3 · Jun 16, 2014 at 04:39 PM · inspectorweaponpickupitem

Making A Universal Pickup Script

Hello Everyone, Right now i am working on a game that has 100 weapons/items that can be picked up my question is if there is a way to assign a variable in the inspector (like savescript.weapon1 = 1) but have is so that i can change what variable is being changed without making 100 different scripts, if anyone has an answer or know where i can find one that would be greatly appreciated! Thanks, -Tom

Comment
Add comment · Show 1
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 ExplodingCookie · Jun 16, 2014 at 04:53 PM 0
Share

So you have a variable that tells the game which of your items you have right?

1 Reply

  • Sort: 
avatar image
2

Answer by ExplodingCookie · Jun 16, 2014 at 05:00 PM

I think I know what you're trying to do here. Attach this script to the pickup item.

 var itemCode = 1; //This tells us which item this pickup is
 var saveState : //Replace this comment with the name of the save state script
 
 function OnTriggerEnter (col : Collider) {
     if(col.gameObject.tag == "Player") { //This lets us see that the collider we hit is the player
         saveState.weapon1 = itemCode; //Sets the save state to this weapon we picked up
         GameObject.Destroy(gameObject); //Gets rid of the pickup
     }
 }

This script is in JavaScript. Which means that You'll have to do some modifications if get it to work with a C# Save State

~ExplodingCookie

Comment
Add comment · Show 2 · 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 T-D-M-3 · Jun 17, 2014 at 12:44 AM 0
Share

Thanks this is exactly what i had needed!!!

avatar image ExplodingCookie · Jun 17, 2014 at 11:19 AM 1
Share

Don't forget to label that answer as accepted so other people know you have been helped.

Follow this Question

Answers Answers and Comments

22 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 avatar image avatar image avatar image avatar image

Related Questions

Java for android script help??? 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How would go about making a weapon pick up? 3 Answers

make inventory script get variables from item's script 0 Answers

Values lost? 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