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
1
Question by anouriel · Jul 04, 2016 at 01:18 AM · performanceperformance optimization

Simple POP UP Damage Script-Animation

alt textalt text

Hi guys i am facing a perfomance problem and i dont know the reason is someone can see the code and answer me it will be helpful , I am trying to make a simple script that pop up the damage that you get like the photo below , the problem is that is working fine but i think is getting a bit laggy over time, i am creating i 3d text object that shows the damage and then i destroy it , because you can get multiple hits (creating multiple 3dtext object and then destroy it ) .

  public void PopUpDamage(float amount)
     {
         float currentTimeMillisecond = Time.time * 1000;
         Vector3 positionPrefab3DText = m_3DTextPrefab.transform.position;
         GameObject gameObject3DText =null;
 
         if ((currentTimeMillisecond - m_PreviousTimerMilisecond) > 1500 || m_EscalateTimes > 5) // If escalates 5 Times or time passed :: 1500 millisecond reset :: Starts From The Bottom ::
         {
             //Reset
             gameObject3DText = Instantiate(m_3DTextPrefab, positionPrefab3DText, m_3DTextPrefab.transform.rotation) as GameObject;
 
             m_PreviousTimerMilisecond = currentTimeMillisecond;
             m_EscalateY3DText = positionPrefab3DText.y;
             m_EscalateTimes = 0;
         }
         else {
 
             m_EscalateY3DText += 0.5f; //escalate Y = 0.5 Every Loop
 
             positionPrefab3DText = new Vector3(positionPrefab3DText.x, m_EscalateY3DText, positionPrefab3DText.z);
             m_PreviousTimerMilisecond = currentTimeMillisecond;
 
             //Anime The Damage
             gameObject3DText = Instantiate(m_3DTextPrefab, positionPrefab3DText, m_3DTextPrefab.transform.rotation) as GameObject;
 
             m_EscalateTimes += 1;
         }
 
         TextMesh m_3DTextMesh = gameObject3DText.GetComponent<TextMesh>();
         m_3DTextMesh.text = "-" + amount + " HP";
         Destroy(gameObject3DText, 0.5f); // Destroy 3d Text in 0.5
 
     }


screenshot-2.png (79.2 kB)
screenshot-1.png (232.9 kB)
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

any physical/practical limit to number of lights in view? 0 Answers

Low performance on Mobile build of 2D Platformer game. 1 Answer

Is UI system much worse in terms of performance than using 2D sprite? 0 Answers

Why is my Custom Inspector Causing Performance Issues? 0 Answers

Different pc performance problem 0 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