• 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 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 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 0
Share

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

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
1

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
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 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 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?

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

95 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

Related Questions

OnCollisionEnter2D being called upon exiting collider? 1 Answer

OnCollisonEnter2D. 1 Answer

onCollisionEnter not being called 2 Answers

Track all colliding Collider2D. 1 Answer

make OnCollisionEnter2D ignore collisons of child objects 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges