Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 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.

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

Isometric diagonal movement (not 45 degrees) in a 2D game C# 0 Answers

Top down real-time strategy. 1 Answer

Limit number of spawning for certain prefabs 0 Answers

Trying to make a side scroller. I'm following a tutorial and getting this error. 1 Answer

IsTouchingLayers() is not working 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