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 /
avatar image
0
Question by Doneyes · Sep 06, 2013 at 12:52 AM · debugloghealth

Debug log doesn't always activate?

In this part of my script, should the debug log not print this1, 2, and 3 each time it hits the requirement? I think this is the reason my script isn't working properly. It does debug log the health near the bottom of the script every time it hits the requirement though. Sorry if the coding is extremely dirty.

 function OnCollisionEnter(other : Collision) {
     if(other.collider.GetComponent(HealthSystem)) {
         Debug.Log("This1");
         HealthS = other.collider.GetComponent(HealthSystem);
         Debug.Log("This2");
         Health = HealthS.Central.GetComponent(CentralHealth).Health;
         Debug.Log("This3");
         Debug.Log(Health);
         if(HealthS.IsHead == true) {
             Debug.Log("Hit something!");
             Health -= Damage;
         }
         if(HealthS.IsTorso == true) {
             Debug.Log("Hit something!");
             Health -= Damage / 2;
         }
         if(HealthS.IsArm == true) {
             Health -= Damage / 3;
         }
         if(HealthS.IsLeg == true) {
             Health -= Damage / 2.5;
         }
         if(HealthS.IsOther == true) {
             Health -= Damage / 2;
         }
         Debug.Log(Health);
     }
     else {
         Debug.Log(other.collider.name + " Does not have HealthSystem script attached! ");
     }
     
     //if(hit.gameObject.tag != "Metal" && hit.gameObject.tag != "Wood" && hit.gameObject.tag != "Stone" && hit.gameObject.tag != "Dirt") {
     
     //}
     
     Destroy (gameObject);
     }
Comment
Add comment · Show 7
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 perchik · Sep 06, 2013 at 12:58 AM 2
Share

Be sure you don't have (Collapse) checked on the log pane, it won't repeat messages if you do

avatar image Doneyes · Sep 06, 2013 at 01:10 AM 0
Share

Yep, completely right. Still gotta figure out the issue though...

avatar image perchik · Sep 06, 2013 at 01:13 AM 0
Share

So it's hitting line 26 above but not the other debug lines?

avatar image Doneyes · Sep 06, 2013 at 01:18 AM 0
Share

No it is, but my system is screwed up. The damage is given to the health value, but nothing actually happens.

Every time line 8 prints 100 (healths value I manually set) and line 26 prints Health with the damage added on. It does that every time I shoot.

Shouldn't line 8 adjust to the newly assigned value?? Why does it just reset?

avatar image perchik · Sep 06, 2013 at 01:20 AM 0
Share

ok, so the debug.log statements are printing out, they're just not showing you what you expect?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Will Davis · Sep 06, 2013 at 10:14 AM

Looks like a scope issue of Health verses the HealthS.Central.GetComponent(CentralHealth).Health..

what about HealthS.Central.GetComponent(CentralHealth).Health = Health; before destroying the gameobject? does that give better results.

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

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

17 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

Related Questions

Health value isn't subtracting correctly 1 Answer

A node in a childnode? 1 Answer

Can I see debug log(ex:printf) from C++ dll in Unity? 0 Answers

Stack Trace returns null ?? wtf with my unity today? 3 Answers

Death upon health = 0 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