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 CaptainHeadset · Jul 26, 2012 at 01:35 PM · collisiontriggercollidersaccuracy

Trigger Colission not only works sometimes

Hi lovely people of the Unity community,

I have a trigger problem. I have a sphere, with a sphere collider. This Collider is a trigger, because i dont want it to react to any physics. Then i have a second game object, a box with the tag Enemy. This box has a rigidbody.

The problem is that when the sphere trigger collides with the rigidbody of the Enemy object, the collision doesnt do anything most of the time. The weird thing (for me) is that the code does kind of work. It only detects collisions some times, but i cant figure out why.

this is the code i'm using:

 function OnTriggerStay(theCollision : Collider)
 {
  if (Input.GetButtonUp("Fire1"))
  {
  if(theCollision.tag == "Enemy")
  {
    Debug.Log("Hit Enemy");
  }
  else
  {
  Debug.Log("doesnt hit Enemy");
  }
  }
 }

I tried using a few variations of onTrigger, like onTriggerEnter, -Exit and -Stay. All without success.

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 DESTRUKTORR · Jul 26, 2012 at 01:36 PM 0
Share

You should use script tags when you paste script. Just highlight the code you have in the question/answer and click the "101010" button at the top bar.

avatar image whydoidoit · Jul 26, 2012 at 01:50 PM 0
Share

The thing with the rigidbody will get the events, is that where the script is?

avatar image CaptainHeadset · Jul 27, 2012 at 05:44 PM 0
Share

This script is on the sphere, the trigger. I'll try putting it on the object with the rigidbody and get back to you. @DESTRU$$anonymous$$TORR, my apologies. I thought I did, but it didnt take the first time. Fixed it now.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Mischa · Jul 27, 2012 at 06:26 PM

Maybe your Rigidbody is sleeping and not processing any collisions. Some information about that problem (it is a feature in the first place :D) can be found here: http://docs.unity3d.com/Documentation/Components/RigidbodySleeping.html

Comment
Add comment · Show 2 · 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 CaptainHeadset · Jul 27, 2012 at 10:53 PM 0
Share

I think thats the problem. When i added a second rigidbody, on the spere this time. When i try to hit it now, its more accurate, but it seems to only work when one of the rigidbodies is moving. Is there an alternative that i could use ins$$anonymous$$d of the trigger colliders?

avatar image CaptainHeadset · Jul 28, 2012 at 12:12 AM 0
Share

actually, think i fixed it. I set the Collision Detection on Continuous and it works now. Thanks for the tip on where to look!

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

8 People are following this question.

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

Related Questions

How do I make colliders collide when Tİme Scale is zero? 1 Answer

Box mechanic: Is it possible to know when the box is closed on all margins? 1 Answer

Temporarily ignore collisions between player and enemies 2 Answers

kinematic trigger with static collider-no trigger message? 0 Answers

changing gravity OnTriggerEnter 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