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 Ingen · Aug 02, 2012 at 04:41 AM · collisiontrigger

strange behavior on collision

Hello, I use this script to chop some trees

  var Hardnes = 5;
  var damage = 1;
  var time :float;// ("is time");
  
  function OnTriggerEnter (coll : Collider) 
  {
     if(coll.gameObject.tag == "axe")
       {  
          Hardnes -= damage;
           Debug.Log ("CHOP");
             if(Hardnes == 0)
              {
                Slice();
              }
       }
  }     
    
   
 
  function   Slice(){
     gameObject.AddComponent ("Rigidbody");
        Debug.Log ("slice column");
         collider.isTrigger = false;
          yield WaitForSeconds (time);
           rigidbody.isKinematic = true;
   
  }

if I give 1 hardnes at 4 tree object all go good

if I give 2 or more of hardness and chop 1 object. the other dosen't work, seem random collision detection

but if I hit the object in sequence, 1 hit to the 1° - 1 hit to the 2°- 1 hit to the 3°- object then restart, all work

do you know why, and how avoid this

thanks in advance

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Aug 02, 2012 at 06:33 PM

probably you don't move away 'axe' object after collider enter. OnTriggerEnter() method called every time collider enters trigger, but between enters it should exit.

add OnTriggerExit() method with Debug.Log() to check this. if you are not exiting - that's a problem

Comment
Add comment · Show 6 · 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 Ingen · Aug 02, 2012 at 11:06 PM 0
Share

it's happened though I move from an object to another and certainly I exit the collider the debug have the same result

avatar image ScroodgeM · Aug 03, 2012 at 07:19 AM 0
Share

hmm... i lost thread a little 8)

does 'axe' exiting from trigger between hits? does OnTriggerExit() calls after hit happened?

avatar image Ingen · Aug 03, 2012 at 07:43 AM 0
Share

I don't use OnTriggerExit, try to add it with a Debulog

and do a video maybe explain better to me

avatar image ScroodgeM · Aug 03, 2012 at 07:53 AM 0
Share

do a video??? 8))))

function OnTriggerExit(coll : Collider) 
{
    Debug.Log ("obj with tag " + coll.gameObject.tag + " is exited");
}    

add this near with OnTriggerEnter method. it should log for trigger-exiting events. check that axe exited it before next chop.

avatar image Ingen · Aug 03, 2012 at 02:22 PM 0
Share

just to demonstrate how not work, it's go only if jump from one to another, sorry bad quality

I'm almost to surrender, too much bug on collision

http://www.youtube.com/watch?v=quBXDtgtzq0

Show more comments

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

Destroy(other.gameObject) isn't destroying parent, only children 2 Answers

Compound collider does not trigger the parent 1 Answer

get only one colliding body 3 Answers

Plane flyby triggering/help 1 Answer

Animation with frozen player ?? 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