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
0
Question by Satish004 · Aug 12, 2019 at 02:50 PM · rigidbody2dcollision2d

OnCollisionEnter2D Not Working??

i m making on 2d game

i want the stop my player when touch finish(success line). but when my player touch success line nothing happened??

TouchControll.cs

    void OnCollisionEnter2D(Collision2D col)            //put this script on player game object
     {
         if(col.gameObject.tag== "successfinishtag")  //tag of finish line
         {
             Debug.Log("OnCollisionEnter2D");
        
            //when player touch finish line i want to the stop my player //nothing happend     
             Gamemanager.stopsplayer = true;     //player stop
       
         }
     }

Image:

alt text

alt text

Finishline have Rigidbody2D?? why colllision2D not work ??

capture.png (71.8 kB)
circle-collider.png (73.7 kB)
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

Answer by I_Am_Err00r · Aug 12, 2019 at 03:36 PM

The only thing I can think of is that you don't have the tag defined in the FinishLine or maybe you are capitalizing "successfinishtag" in the inspector or it is not spelled correctly, string references have to be EXACT (in both spelling and case) for them to match.


Personally, I would use a tag of "Finish" or something simple like that.

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 Satish004 · Aug 12, 2019 at 03:42 PM 0
Share

@I_Am_Err00r thanks sir give the answer i giving a tag finish line:

see my image:

alt text

capturesss.png (77.1 kB)
avatar image I_Am_Err00r Satish004 · Aug 12, 2019 at 03:52 PM 0
Share

So was that the issue, just not have a tag definition? Are you still having trouble? If you are, is it at least logging in the console that Debug.log("OnCollisionEnter2D") you put in there?

avatar image satish004004 I_Am_Err00r · Aug 12, 2019 at 05:55 PM 0
Share

@I_Am_Err00r this link say :https://docs.unity3d.com/$$anonymous$$anual/CollidersOverview.html

if u have two rigidbody on your gameobject then collision is posiiblem??can u agree with this? but i put rigidbody both of them(Player,Finishline) collision not run??

Show more comments

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

113 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Player not taking damage on collision with enemy 1 Answer

How can I make walls with Collider2D components for a top-down game in Unity 2018? 1 Answer

2d rigidbody falling from the collider when it is moved 3 Answers

Collision Between 2D Rigidbodies is Jittery (No Movement) 1 Answer

OnCollissionEnter2D not being called 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