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 Aspyn palatnick · Jun 06, 2010 at 03:02 AM · collisiononcollisionenterdetection

onCollisionEnter

I have a cylinder using a mesh collider and rigid body. I also have 2 blocks(cubes) as goals. The cylinder's tag is "SodaCan" The block's tags are "Goal1" and "Goal2"

I created a script called "GoalDetection" and attached it to "Goal1" and "Goal2" GoalDetection uses this exact code:

function onCollisionEnter(other : Collision) {
      if (other.gameObject.tag == "SodaCan") {
            Debug.Log("Goal Scored");
      }
}

My problem is that even when the soda can is right on top of either goal "Goal Scored" is not printed.

Does anybody know any solutions or what i did wrong?

I am using unity iphone

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
5

Answer by Tetrad · Jun 06, 2010 at 03:05 AM

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html

You probably need to capitalize the 'O', like this:

function OnCollisionEnter(other : Collision) 
{ 
    if (other.gameObject.tag == "SodaCan") 
    { 
        Debug.Log("Goal Scored"); 
    } 
}
Comment
Add comment · Show 4 · 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 Aspyn palatnick · Jun 06, 2010 at 05:17 PM 0
Share

it didn't work.

avatar image Tetrad · Jun 06, 2010 at 07:34 PM 0
Share

Do you have triggers set up on your goal objects? I.e. colliders with the "is trigger" checkmark added?

avatar image Aspyn palatnick · Jun 07, 2010 at 08:40 PM 0
Share

No should I put a trigger?

avatar image Tetrad · Jun 07, 2010 at 10:26 PM 0
Share

Re-read the documentation I linked to you, specifically this point: "OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider."

So if your goals don't have either rigidbodies or colliders, OnCollisionEnter won't get called.

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

No one has followed this question yet.

Related Questions

Collision detections fails to re-detect an object 1 Answer

WALL collision detection problem... help!!!! 0 Answers

collision detection 4 Answers

Detect collision from a another object,Detect collision from another script 2 Answers

Collision Detection 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