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
2
Question by Heav3n · Nov 29, 2012 at 10:27 PM · collision

Collide only on top and pass through the other sides

I have a gameobject with rigidbody and collider (sphere for now)

And I have a platform with rigidbody and collider (mesh)

I don't want the 1st gameobject to collide while it passes through from the bottom side but collide only when it lands from the up side.

Any clues?

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

5 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Loius · Nov 29, 2012 at 11:47 PM

Objects can only collide with 'outward-facing' polygons (the face normal has to point towards the incoming object). So objects can always pass through planes from one side, but not the other (assuming the plane's two triangles aren't facing opposite directions).

I'd recommend making a non-collider object for the visual part of the "platform", and use a simple plane collider (or a box collider with no bottom panel) for collision - easy to build in a 3D modeling program, just bring in the default cube object and get rid of the faces you don't want.

(you'll need to use the Mesh Collider to use custom meshes for collision)

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 Heav3n · Nov 30, 2012 at 12:10 AM 0
Share

yes but while it passes through the platform, my OnCollisionEnter event will trigger, right? I want to trigger it only when co$$anonymous$$g from up with direction down.

avatar image Loius · Nov 30, 2012 at 03:03 AM 0
Share

It won't trigger OnCollide unless it actually collides - which means it hits the thing and is affected by physics.

avatar image Heav3n · Nov 30, 2012 at 09:57 PM 0
Share

Yes, I know. But I don't want to collide when it comes from bottom and passes through it. I just want when an object lands onto the collider, from top with direction to bottom ( -Y ).

avatar image
1

Answer by sunweixiao · Nov 10, 2016 at 08:12 AM

A Plane has 2 faces,the front face and the back face. If you attach a collider to this plane.The front face can detect collide and the back face can't. You can rotate your plane for 180 degrees.

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 BiG · Nov 29, 2012 at 10:28 PM

Does this help?

http://answers.unity3d.com/questions/240824/detect-collision-with-the-side-of-an-object.html

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 Heav3n · Nov 29, 2012 at 11:39 PM 0
Share

Thanks for the reply. But that doesn't solve the problem to pass through from the bottom side and collide only when landing on top. I have it like that up to now(2 colliders), when I collide on the bottom collider it deactivates the top and when i exit it activates again. But I was looking for something more efficient.

avatar image
0

Answer by Bunny83 · Nov 30, 2012 at 12:00 AM

I've written a little script which can remove faces from a mesh at runtime based on the normal angle:

http://answers.unity3d.com/questions/236313/one-way-collider.html

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 ozdenmurat · Sep 19, 2020 at 04:55 PM

You can add to your player two different colliders in different places, forexample like this; capsule collider for head, box collider for legs.

         public class Player : MonoBehaviour
         {
              Rigidbody2D rb;
              CapsuleCollider2D myhead;
              BoxCollider2D myfeet;
 
 void Start()
 {
     rb = GetComponent<Rigidbody2D>();
     mycollider = GetComponent<CapsuleCollider2D>();
     myfeet = GetComponent<BoxCollider2D>();
 }

Then you can use colliders for different purpose ;

  private void Jump()
     {
         if (myfeet.IsTouchingLayers(LayerMask.GetMask("Foreground"))) 
         { 
         if (CrossPlatformInputManager.GetButtonDown("Jump"))
         {
             //rb.AddForce(Vector2.up * jumpSpeed);
             rb.velocity += Vector2.up * jumpSpeed;
         }
 }

i hope this will help you.

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

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

17 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

Related Questions

Raycast collision detection? 1 Answer

OnTriggerEnter2D not triggering 2 Answers

ControllerColliderHit, two objects, takes wrong one 1 Answer

Change Direction on Collision 6 Answers

detect power of a hit for VR boxing 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