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 adammcd · Jun 08, 2013 at 08:22 PM · c#collisionrigidbodycollision detectionrigid body

Collision detection from specific directions using rigid body character?

I'm building a 2D platformer using a rigidbody character, and I'm having issues with collision.

I had been using triggers that are children to the character to tell if there was a wall to whatever side of the character, but I ran into problems when hitting walls from different angles.

In other engines/tools such as Flash and Torque, you can look to see if your character would be colliding with an object if it was +1 (or -1 or any other value) in a specific direction. I feel like that would be perfect for this, but I can't figure out how to do it in Unity.

I have seen similar questions answered with links to documentation on contact points, but the contact points seem to detect exactly where in the actual world the contact takes place. I don't see how that would help in this case, but if there is a way to detect the relative distance of a contact point from my character that would probably work.

To make things more complicated, the entire game world is composed of "blocks" that you can hit from 4 different sides. Therefore, I don't think having separate "wall" and "floor" objects is ideal. Even if they are simply different colliders within one object, I can see complications coming up (what happens with corners, for example).

Raycasting does not seem ideal since I'd like to be able to detect collision across each entire side of my character (or very close to it), but I am open to raycasting suggestions.

Just now I tried setting it so that the triggers around my character (there are 8, 2 on each side) determine direction only and collision is handled between the character and other objects normally (using onCollision functions). This seems better than what I had before, but some quick testing has revealed that it still is far from perfect.

I can provide code if needed, but I suspect I will need to completely overhaul how I'm doing this. I am using C#.

At this moment I forget exactly why I decide to use a rigidbody instead of the built in character controller, but I think it was a combination of being able to do what I wanted with physics and the fact that it felt simpler to me at the time.

Any help or insight would be greatly appreciated.

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

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

How to detect collision on only one side of an object? [C#] 4 Answers

Objects with colliders going through walls and each other. 3 Answers

Prevent a specific RB to influence another, but still collide with everything 0 Answers

Force a script generated primitive to test for collision 2 Answers

Collision problem 4 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