• 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
1
Question by HazaTea64 · Jul 30, 2018 at 11:14 AM · 2d-physicsoncollisionenter

How to get contact point of collision.

Making an atari breakout kind of game. The further away from the centre of the paddle the ball hits the more angle I want it to bounce off at.

Thanks.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by samf1111 · Sep 02, 2020 at 01:48 PM

Vector3 globalPositionOfContact = collision.contacts[0].point;

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

Answer by Harinezumi · Jul 30, 2018 at 11:18 AM

The documentation for OnCollisionEnter() gives a pretty good example: the contactPoints member of the Collision parameter gives you an array of contact points.

Comment
Add comment · Show 2 · 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 tazboy · Oct 25, 2019 at 04:12 PM 0
Share

It looks like it gives the user where in space, not on the object, the collision happened. At least that's the results I'm getting.

avatar image Harinezumi tazboy · Jun 01, 2020 at 04:42 PM 0
Share

Yes, it gives world space coordinates, which can usually be used for any purpose. What do you mean by "on the object"? If you want position relative to the object, you can use transform.InverseTransformPoint() (scripting documentation).

avatar image
0

Answer by Destanci · Jul 30, 2018 at 11:18 AM

     private void OnCollisionExit(Collision collision)
     {
         Debug.Log(collision.contacts.Lenght);
     }

collision.contact will return you a Array with ContactPoint s Where 2 Colliders Hits At. Research ContactPoint class at Unity docs will help you.

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 Twinklier · May 24, 2020 at 07:38 AM 0
Share

In the docs it said to avoid using this... eh.. whatever

avatar image Harinezumi Twinklier · Jun 01, 2020 at 03:04 PM 0
Share

I've just looked at the scripting reference and I can't find any mention about avoiding using this. Where did you see this? $$anonymous$$aybe it was trying to avoid using it many times during a frame?

avatar image DarkxxCrow Twinklier · Apr 04 at 06:16 PM 0
Share

just for clarification, the docs disencourage using the contacts property directly to avoid potential memory issues, as opposed to using the method GetContacts()

avatar image
0

Answer by tormentoarmagedoom · Jul 30, 2018 at 11:32 AM

Come on... think about how to do it (not how the code is), but what you need to know, what you need to compare, and look at google or unity how to get that values...

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 tazboy · Jun 01, 2020 at 04:36 PM 1
Share

Just saw this. You assume I didn't do these things. Is this how you normally "help" people?

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

97 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

Related Questions

OnCollisionEnter2D being called upon exiting collider? 1 Answer

OnCollisonEnter2D. 1 Answer

My game after being built has some really weird glitches? 0 Answers

OnCollisionStay2D not working in the way I would like. 1 Answer

Collision of two Gameobjects 0 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