Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
3
Question by Oninji · Oct 27, 2010 at 06:11 PM · collisiongameobjectcolliderontriggerenter

Collision Detection without a RigidBody

Hellow,

I'm using a OnTriggerEnter, but for some reasons.. It doesn't seem to detect the collision.

Used the method on other scripts, all work, but not for this particular one.

Here is the snippet of code

function OnTriggerEnter (other : Collider) {

  if (other.gameObject.GetComponent(Tagger).Meteor == true) {
     other.gameObject.GetComponent(MeteorMove).explode = true;
 }

}

EDIT

Saw it was because I missed that I needed the RigidBody. Is there a way to get a similar result as a OnTriggerEnter without a RigidBody?

Comment
Add comment · Show 4
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 equalsequals · Oct 27, 2010 at 06:20 PM 0
Share

$$anonymous$$y suggestion to you is throw a print statement just before that if statement and see if the function is even firing. If so, your problem could be that the collider's game object doesn't have the component you're looking for or perhaps the code you're triggering (the boolean explode) doesn't give you the visual feedback you're expecting so you believe it isn't doing anything. Just a thought. Cheers. ==

avatar image skovacs1 · Oct 27, 2010 at 06:44 PM -1
Share

Do you realize that "Hellow" is not a word? The word you seem to be looking for would be "Hello". After reading this in several of your questions, I thought it best to let you know. It's not likely a typo because 'w' is so far from the 'o' or ',' that you are typing around it. It's even more odd as a few of your questions don't have this mistake.

avatar image Oninji · Oct 27, 2010 at 06:51 PM 0
Share

@Skovacs, that's plain unconstructive.... @equalsequals I was checking through the inspector and did used print. But well, as I stated in the edit I had forgot that I needed the Rigidbody to fire the function. So now I'm checking around to found another mean of trigerring my function is a similar maneer without using a rigidbody. But thanks.

avatar image skovacs1 · Oct 27, 2010 at 07:00 PM 0
Share

@Oninji - How is that not constructive? I am helping you 'construct' better English sentences and questions. I don't mean it in a malicious or critical way. I was simply trying to help you improve your English language skills. I wouldn't have mentioned it if you hadn't made the same mistake in 11 of your 14 questions.

2 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by skovacs1 · Oct 27, 2010 at 06:35 PM

I assume you are asking, "Why is this collision not being detected?" rather than something else about the undetected collision.

As per equalsequals' comment, it is possible that the collision is happening, but that your if statement or however you are identifying that the collision is happening is failing rather than the collision not being detected. Using Debug.Log and/or print statements would help you identify which is the case.

The docs on OnTriggerEnter clearly state:

Note that trigger events are only sent if one of the colliders also has a rigid body attached.

Do you have a Rigidbody or CharacterController on one of the colliders?

How fast is your object moving? It is possible that one collider is passing over the other without generating a collision. If this is the case, it would be better to adjust your scene, but if that is not feasible, then if you have a Rigidbody, you might consider changing your Rigidbody's collision detection to Continuous.

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 Oninji · Oct 27, 2010 at 06:42 PM 0
Share

Just before you answered, saw the note in script reference. So my question would now be... How to achieve similar results without a RigidBody?

avatar image skovacs1 · Oct 27, 2010 at 07:03 PM 0
Share

If you do not have a Rigidbody or CharacterCollider, OnTriggerEnter() will not be called. If you cannot have one of those, then you will have to check for the collisions with either raycasts, spherecasts or capsulecasts in an update function of some variety.

avatar image tonydemot · Sep 18, 2012 at 03:22 PM 0
Share

you can always have a rigidbody without gravity have you tested that out if that's what you are looking for.

avatar image
4

Answer by Jonas Planck · Oct 27, 2012 at 08:44 AM

I just spent a few hours banging my head against this problem... I found a solution by adding a rigidbody component, and opening the constraint dropdown of that component and checking all the boxes. This way, the object still collides with the trigger, but it's not at the mercy of physics, and it still obeys it's transform instructions.

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 whydoidoit · Oct 27, 2012 at 08:45 AM 1
Share

You only have to set is$$anonymous$$inematic = true for the object not to be at the mercy of physics. See this unityGE$$anonymous$$S article for a discussion of how to make collisions and triggers work.

avatar image Jonas Planck · Oct 27, 2012 at 09:35 AM 0
Share

@whydoidoit: Thanks! This resource will come in very handy... I'm also new to scripting, so this will help me in ways I haven't even foreseen yet.

avatar image jbarbeau · Jun 30, 2015 at 01:01 AM -1
Share

Thanks JONAS, I had an invisible plane that I wanted to create an OnCollisionEvent. But I didn't want it to interact with the object passing through it. Your solution solved my problem, although I'm not sure if there is a processing penalty.

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

Collider Error[SOLVED] 2 Answers

Collision Checking 1 Answer

Colliding two GameObjects 1 Answer

How to adjust two colliders really close to each other w/o them colliding? 1 Answer

super mario pipe physics? 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