Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Dionysos1111 · Dec 15, 2017 at 02:15 PM · performancemissions

A better way to do it

I'm using unity to make a game. I have multiple animal enemies in the game.

I'm working on missions inside the game that you have to kill a random number of random animals, this i already have.

What i have a problem with is to increase the mission count when you kill an animal.

I got a script (dead) sitting on each animal, when the animal dies it calls a public function inside the dead script.

from the dead script it should increase an int value in the "MissionHolder" script where all the animals have a int value to increase when you kill a animal.

The problem is i don't know which animal gets killed when the player kills a animal, what i did is this...:`

 public string Name;
 public MissionHolder missionHolder;
     public void Kill()
 {
     if (name == "Tiger")
     {
         missionHolder.Tiger += 1;
     }
 
     if (name == "Hyena")
     {
         missionHolder.Hyena += 1;
     }
 
     if (name == "Gorilla")
     {
         missionHolder.Gorilla += 1;
     }
 
     if (name == "Giraffe")
     {
         missionHolder.Giraffe += 1;
     }
 
     if (name == "Gazelle")
     {
         missionHolder.Gazelle += 1;
     }


etc.

Now i just name each animal by it's name on the dead script but this is not really efficient.

Does anyone knows a better way to do this?

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 KittenSnipes · Dec 15, 2017 at 02:23 PM 0
Share

@Dionysos1111

Well I am having a bit of trouble here. So everything works? All you want is a better way to do it. Well maybe you can classify a list of strings that you reference from. $$anonymous$$ake a class where you classify an animal by the gameObject and then a string in which will be it’s name. Such as referencing the game object of the tiger and classifying the string as tiger and every time you kill that game object you know it’s a tiger.

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

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

Related Questions

.Exe gets slower over time 0 Answers

Cross-Scene Simulation? 0 Answers

FPS drop beacause Dialog with 200 images in it 0 Answers

AMD RYZEN 1800X or Intel i7 7700K? 2 Answers

Should you instantiate new particle systems or keep them active inside gameobjects? 2 Answers


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