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 Saishy · Jun 14, 2013 at 09:34 PM · collisioncollisiondetectioncollision-error

Collider colliding with itself

     void OnCollisionEnter(Collision other) {
         GameObject otherGameObject = other.gameObject;
         
         if (otherGameObject == gameObject) {
             Debug.LogError("WAT");
             return;
         }
         
         if (otherGameObject == player && bDamageOnTouch) {
             player.GetComponent<HealthController>().TakeDamage(damage);
             bMoving = false;
             timerMovement = timeToMove;
         }
     }


alt text

Wat

Comment
Add comment · Show 8
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 bodec · Jun 14, 2013 at 09:43 PM 0
Share

your debug is just checking that otherGameObject is a gameobject and it is. assigning other to another variable is not needed you can use other.whatever you would get from gameobject. a description of what is happening would also help posting the code and then expecting us to guess what is going on does not work.

avatar image Saishy · Jun 14, 2013 at 09:47 PM 0
Share

No it's not, first at all this should be obviously as you can't check types by doing ("variable" == "type"). Second and even more obvious by the fact that gameObject is a reference to the GameObject owning the script. And the fact that gameObject starts with lowercase and GameObject not.

avatar image bodec · Jun 14, 2013 at 10:06 PM 0
Share

never the less you still have provided no assistance in helping you.

avatar image Saishy · Jun 14, 2013 at 10:22 PM 0
Share

Any more information is superfluous, giving it will only attract people who don't know what is going on and try baseless assumptions which will delay the right answer.

Steps to reproduce: Create a box gameobject, give it a rigidbody, character controller and script a OnCollisionEnter, make the check. It will collide with itself, two times.

avatar image scone · Jun 14, 2013 at 11:30 PM 0
Share

Saishy, this doesn't happen for me. There must be some other collider on the object or something else is going on :(

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by theAfrican · Jun 14, 2013 at 11:07 PM

are you trying to check for tag here?

if (otherGameObject == player)

what is player supposed to be? string or actual previously defined GameObject?

if its a tag then player should be a "string"

otherwise if player is a name of gameobject then you should compare using the .name property which is a string

Comment
Add comment · Show 1 · 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 Saishy · Jun 14, 2013 at 11:18 PM 0
Share

if (otherGameObject == gameObject) { Debug.LogError("WAT"); return; }

Note return;

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

18 People are following this question.

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

Related Questions

Not detecting collision on imported (DAE) objects? 1 Answer

collision detection not working? 1 Answer

Collision Enter one of the objects ? 1 Answer

Obstacle avoidance 1 Answer

Collision detection for sprite 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