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 DJSwiti · Apr 08, 2012 at 05:11 PM · collisioncollision.contacts

Be on a cube and be collided with that cube you are on.

Hello.

My quesiton is quite simple, i would like to make things like that :

I am on the ground (Plane). When i go on a cube (cube) which is Y = 0,1, i would like the Player enters in collision with the Cube, because it's the case..

I already checked theses functions :

 void OnCollisionStay(Collision collision) {
         foreach (ContactPoint contact in collision.contacts) {
             ...
         }
     }

and

 void OnTriggerEnter(Collider col) {
         if(col.gameObject.tag == "Player"){
             ...
         }
      }

But none works ...

Can anybody explain me how does the contacts are made ? And by the way, a solution for my problem.

Thanks

Comment
Add comment · Show 2
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 ExTheSea · Apr 08, 2012 at 05:31 PM 0
Share

look whether you checked is trigger on the box collider.

avatar image DJSwiti · Apr 08, 2012 at 05:49 PM 0
Share

Yea, all my box or capsule collider are trigger.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by fafase · Apr 08, 2012 at 05:49 PM

OnTriggerEnter is used if you want to get through the object.You tick IsTrigger on the collider. For example you want to have a zone in the game that trigger something(a gui will show up for example or launching an animation), you use this one because you don't want to bump into an invisible shape. Simply put trigger are ignored by the physic engine

OnCollisionEnter is used when you want to keep the interaction between the two colliders. Without IsTrigger and this function you check collision and only a tiny part of the bounding volume actually interacts (not enough to be seen).

Now if you want to stay on the box, just add a box collider to it. If your guy has a character controller he will stay on top of it.

You can check collision with OnControllerColliderHit

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

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 DJSwiti · Apr 08, 2012 at 06:33 PM 0
Share

Thanks alot :)

avatar image
0

Answer by ExTheSea · Apr 08, 2012 at 05:53 PM

Is your collider you refer to in the second example a trigger? If it's not you can't access it through OnTriggerEnter.

So you should check IsTrigger on the box collider if it isn't already.

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

Not detecting a simple collision? 2 Answers

How to get ALL Contact Points from EVERY Collision on a Rigidbody? 0 Answers

Find axis of collision 0 Answers

collision.contacts never has more than 1 element 1 Answer

Collision Problem - Floor Button & Character Controller 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