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
1
Question by Galatia410 · Mar 30, 2017 at 03:01 AM · collisioncollision detectionontriggerenter

OnTriggerEnter Issue?

ok so im totally stumped... I have a helper creature in my game that targets an enemy goes to them and then the enemy dies on contact, and an enemy that comes to the main character then blows up and does damage. they both work perfectly, all on trigger functions work on both of them with every other creature they encounter until they run into each other. the enemy guy should die and its not even registering a collision between the two. my helper just starts spinning very fast circles around/inside the enemy. I thought maybe i had a typo with the tag so i copied it directly from a enemy he was destroying and still no luck. here is my code if anyone can help me spot a problem. its the when hes hit by "HelperM". its not printing or anything. both guys have box colliders. Is there a better way to be detecting collisions or any suggestions how to find/fix the issue?

 void OnTriggerEnter(Collider hit)
 {
     if (hit.gameObject.tag == "ffball")
     {
         dt = 50;
         damage = true;
         DamageFromPlayer();
     }
     if (hit.gameObject.tag == "feball")
     {
         dt = 35;
         damage = true;
         DamageFromPlayer();
     }
     if (hit.gameObject.tag == "DeathWorm")
     {
         dead = true;
     }
     if (hit.gameObject.tag == "fbullet")
     {
         dt = 35;
         damage = true;
         DamageFromPlayer();
     }
     if (hit.gameObject.tag == "HelperM")
     {
         dead = true;
         print("Got Hit By HelperM");
     }
 }
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
Best Answer

Answer by meat5000 · Mar 29, 2017 at 04:32 PM

Looks like you should have at least 1 rigidbody (non-K) and OnCollision routines... not triggers.

Comment
Add comment · Show 3 · 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 Galatia410 · Mar 30, 2017 at 12:32 AM 0
Share

I tried using OnCollision but was having the same outcome with those. Ill change the code to that because it does make more sense, but still doesn't solve the issue. what did you mean by having a rigidbody (non-k)? that is something i haven't tried but kinda confused with what exactly your suggesting?

avatar image Galatia410 · Mar 30, 2017 at 01:25 AM 0
Share

Thank you, I tried adding a rigidbody and that solved the issue.

avatar image meat5000 ♦ Galatia410 · Mar 30, 2017 at 10:12 AM 0
Share

No problem. Non-$$anonymous$$ is non-kinematic. This means it responds to physics. $$anonymous$$inematic bodies kinda hang in space and are not freely movable objects.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Could some one help me with this script... 5 Answers

OnTriggerEnter not working in running game 4 Answers

Destroying object on collision 3 Answers

Can I have a single rigidbody2d that acts as both collider and trigger? 1 Answer

Objects don't collide 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