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 /
avatar image
0
Question by fhvnb · Jan 16, 2017 at 01:52 PM · timerscoredoublexpmultiply

Multiplying a feed after kill

I have a score feed, which displays a text that says "15+" when ever i kill an enemy, but the problem is, if i shoot multiple enemies in a small time range it will just show "15+" throughout it, so it would be hard to distinguish between each kill. I want it to double whenever i get multiple kills within a certain time range (i know it says multiply in the title, but it looks better.). Here is an example from CoD: https://www.youtube.com/watch?v=aU8OKGlYpfk

I've searched it up, but i still can't find a good solution, i've been pondering for a while now.

XP feed code, that pops up a text (saying 15+) whenever i kill someone:

  public class XpFeed : MonoBehaviour {
 
     public float showtime;
     Text text;
     public int xpFeed;
 
     void Awake()
     {
         // Set up the reference.
         text = GetComponent<Text>();
 
         // Reset the score.
     }
 
     void Update()
     {
         // Set the displayed text to be the word "Score" followed by the score value.
         text.text = "+" + xpFeed + "xp";
     }
 
     public void getFeed()
     {
         StopCoroutine("showfeed");
         text.enabled = true;
         StartCoroutine("showfeed");
     }
 
     public IEnumerator showfeed()
     {
         yield return new WaitForSeconds(showtime);
         text.enabled = false;
     }
 }

And enemy AI code:

 public class AIHealth : MonoBehaviour
 {
 
     public int xpValue = 15;
     public GameObject xpfeed;
     
     void Awake()
     {        
         xpfeed = GameObject.Find("XPFeed");
     }
 
     void Death()
     {
         XPManager.curXp += xpValue;
         xpfeed.GetComponent<XpFeed>().getFeed();
     }
 }


Comment
Add comment · Show 3
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 fhvnb · Jan 17, 2017 at 11:14 PM 0
Share

I'm back to bump :)

avatar image GarretLawrence · Jan 18, 2017 at 03:01 AM 0
Share

Then ins$$anonymous$$d of using only 1 permanent text object, you can make a text prefab. After you killed an enemy, spawn that text prefab (make it fall down in 1~2s then destroy it).

If you only want to use 1 text object, then after you killed an enemy, enable that text and make zoom effect, if you kill another target in a short time then just instantly resize it to original size then zoom it again.

avatar image fhvnb · Jan 18, 2017 at 08:24 AM 0
Share

I really need some help here guys, anything really :)

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by ForeignGod · Jan 18, 2017 at 09:20 AM

Make a timer.

Each time you get a kill set timer at 3sec or something.

Check if timer is more than 0 and if it is add 15 to your xpfeed variable.

If timer is 0 do your regular code.

Comment
Add comment · 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
1

Answer by KarenCrawford · Jan 18, 2017 at 09:11 AM

You can check youtube for ´scrolling combat text tutorial´ and do a similar solution to that if you are having a lot of messages incoming.

In my game, it was much slower and I could never have more than 2 messages at a time, so I did an easier solution. I had two text boxes, Primary and Secondary with primary slightly below secondary.

then I did

 If ( primary is active in hierarchy)
      put text in secondary
 else 
     put text in primary.

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 fhvnb · Jan 18, 2017 at 12:32 PM 0
Share

I guess that could work, i'll give it a shot and see if i like it :) Thank you :)

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

7 People are following this question.

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

Related Questions

How do I add used Time in scoreboard 0 Answers

Loading a score on a scene 2 Answers

Score and Level Loading 1 Answer

Get score in areas 0 Answers

Why can't I call function from another script? 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