• 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 bw_o2 · Jul 10, 2018 at 11:21 AM · 2d gamecolliding

i want to know object's collding side!

When play collide with object, i want to player work differently. If player collide with upside, then player's speed get up. But palyer coliide with downside, player's speed get down! If you know function that can get object's colliding side(up, down, left, right), please help me!! I use C# language.

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 JVene · Jul 10, 2018 at 11:39 AM

In OnCollisionEnter, the Collision parameter includes Contacts, a list of points of contacts and information about what was colliding. From there you can deduce where the contact occurred.

If that is too complicated to use (and sometimes it's just not that simple), you could simply put different colliders on the two sides which gives you two different scripts, one for the upside, one of the downside, which makes this quite obvious and simple.

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 bw_o2 · Jul 10, 2018 at 12:45 PM 0
Share

I am found about Contacts , but ,i think, it just can get a point of colliding. I am finding solution really hard, but they just give me solution about a point ,not a edge. I want to make game like Super$$anonymous$$ario. And i dont use physical 2D gravity for some reason. (Player move from transform.Translate.) When player contact ground, player just stick to ground whatever colliding side is. For that reason, i want to get colliding side(edge) to solve my problem. I should solve my problem from a point? if so, i try to that way. But i dont know there are already made function. In Contacts, can i get information about colliding side(edge)?

avatar image JVene bw_o2 · Jul 10, 2018 at 05:55 PM 0
Share

A point can identify a side, so yes you can solve this problem with a point of contact. You can start an evaluation by using OnEnterCollision, and look at the list of contact points. They're in global coordinates, but you can transform them into local coordinates to see the relevant location of the impact. With your knowledge of the model, you should see obvious patterns about the coordinates you see that identify the side of the contact. Think of this another way, if you selected a point on the model, could you tell where that point is?

However, re-read my original answer for option 2. I think it is more appropriate for you.

You should consider placing multiple colliders at the key positions you want to sense. Consider them sensors you install to cover the important parts, up/down/left/right. Now, when the up collider is hit, that's the collider that gets informed. The decision about which collider has been hit is made for you. It's much simpler.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

99 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

Related Questions

How to make "2D One More Jump" type game in unity 0 Answers

Zone interactable and no-interactable with an object Unity 2d 0 Answers

Raycasting not working as expected: rays are perpendicular to projectile's trajectory and collision doesn't occur 1 Answer

Using MoveTowards on button click 0 Answers

Where do I draw images? 2 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