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
2
Question by nois0a · Apr 22, 2012 at 03:46 PM · collisionrigidbodyoncollisionenterrigidbody-collision

OnCollisionEnter and rigidbody problem

Hi, i have searched around theese forums for a solution for my collision problem but nothing works. I simply want my player to collide with a boat but nothing happens. Both objects are rigidbodys and have mesh colliders. The boat is tagged "Boat". I would like to destroy the boat when the player collides with it. Debug log doesn't respond either.

Everyone says I should use a script like this:

function OnCollisionEnter(collision:Collision)

{

 if(collision.gameObject.tag == "Boat")
 {
     Debug.Log("Hit!");
 }

}

Help would be appreciated :)

Comment
Add comment · Show 7
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 fafase · Apr 22, 2012 at 03:46 PM 0
Share

Is the player at least bouncing against the boat or is it going through? Do you have one collider set to IsTrigger?

avatar image Owen-Reynolds · Apr 22, 2012 at 04:28 PM 3
Share

Two $$anonymous$$eshColliders need extra work to collide with each other. As a test, give one (or both) just a box or sphere collider.

If that works, either read up on setting convex $$anonymous$$C's, or about making compound colliders (for a big, ugly mesh, sometimes easier to just cover it with some standard box and capsule colliders.)

avatar image nois0a · Apr 29, 2012 at 09:31 PM 0
Share

i have no idea why but it works now. anyways, thanks for the reply.

avatar image nois0a · Apr 29, 2012 at 09:37 PM 0
Share

maybe it was because i changes the collider to a box collider. $$anonymous$$esh collider doesn't seem to work for my model.

avatar image Bluntweapon · Apr 30, 2012 at 06:22 AM 2
Share

$$anonymous$$esh Colliders do not normally collide with other $$anonymous$$esh Colliders, as Owen above have stated. You'd have to go about making the $$anonymous$$C Convex, which is a separate topic altogether.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by maroonrs2 · Apr 30, 2012 at 03:08 AM

 function OnCollisionEnter (hit : Collision)
 {
     if(collision.gameObject.CompareTag("Boat"))
     {
         Debug.Log("Hit!");
     }
 }

make sure you tag your boat. Also make sure Is Kineticable is off, for this disables it.

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 venkspower · Apr 30, 2012 at 04:20 AM 1
Share

But where have you defined the "collision"? But you have used it in the script. And you have defined "hit" and never used it! This is peculiar!

avatar image maroonrs2 · Apr 30, 2012 at 04:32 AM 0
Share

opps thanks for catching that lol. I ran into a problem with On not capatalized. and also CompareTag is the best way as you cannot read what .tag is and compare it at the same time.

avatar image venkspower · Apr 30, 2012 at 06:19 AM 0
Share

Edit your answer. Do not misguide.

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

Collision Only being detected on one of the objects involved in the collision - C# 0 Answers

what object hit me? easy rigidbody question 1 Answer

A bit confused with OnCollision and Rigidbodys 0 Answers

Rigidbody slightly intrudes another one while pushing it 1 Answer

Further collision beyond the OnCollisionEnter() event 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