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
1
Question by NikolaP · Aug 31, 2016 at 07:01 AM · c#physics2dcollider2dcollision2d

Edge Collider issue

Here is a video where i showcase the issue. The edges have box colliders attached to them. I tried changing the max penetration in the Physics2DSettings but it still acts weirdly... I also tried changing the "Collision Detection" property to continuous on the rigidbody component, but it still didn't work. So is there any way to fix this? I assume it has something to do with how unity collisions work :/

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
4
Best Answer

Answer by MelvMay · Aug 31, 2016 at 08:57 AM

First, reset the max-penetration back to its default; it's actually very bad to change it unless you know what you're doing.

Unity 2D physics (Box2D) provides rock solid detection for this kind of thing, especially continuous collision detection which you should definitately use for faster moving objects against thin colliders like edges.

The most likely reason it's happening is because you're causing an overlap with the edge by modifying the Transform component on your 'player' to either reposition it or change the angle. When you do this, you're warping it from one position/angle, instantly to another causing the overlap which the physics system cannot easily solve, especially if you're doing this continuously, stomping over what it's doing.

You should use Rigidbody2D.MovePosition & Rigidbody2D.MoveRotation to change the position and angle of the Rigidbody2D respectively.

Comment
Add comment · Show 5 · 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 NikolaP · Aug 31, 2016 at 10:08 AM 0
Share

I didn't notice that my rotation is using transform to rotate. This was the code that i was using transform.Rotate(rotationSpeed * new Vector3(0, 0, -10) * Time.deltaTime); and this is the code that i got from the unity documentation Quaternion deltaRotation = Quaternion.Euler(rotationSpeed * Time.deltaTime); myRigidbody.$$anonymous$$oveRotation(myRigidbody.rotation * deltaRotation); But i am getting an error on the second line: "Operator '*' cannot be applied to operands of type 'float' and 'Quaternion'.

avatar image NikolaP NikolaP · Aug 31, 2016 at 11:07 AM 0
Share

I actually fixed it by calling the function from fixed update since * Time.deltatime didn't work, and the command is rigidbody.rotation = rigidbody.rotation + / - rotationSpeed. I set the collision detection to continuous and i reset the max penetration, it still glitches and goes through...

avatar image MelvMay ♦♦ NikolaP · Aug 31, 2016 at 12:06 PM 1
Share

it still glitches and goes through...

That's because you're missing the reason why I explained previously. Again, you cannot simply reposition or change angle of a body continuously either via the Transform component or directly on the body itself and expect collision detection to work correctly; you are fighting the physics system. The physics system expects to move the position/angle itself via the linear/angular velocity; this is what Rigidbody2D.$$anonymous$$ovePosition and Rigidbody2D.$$anonymous$$oveRotation does i.e. calculate the velocity required to move the position/rotation during the next fixed update.
Show more comments

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

214 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

OnTriggerEnter2D working, OnColliderEnter2D not working 1 Answer

OnTriggerExit2D Does not work 1 Answer

Ignore collision before instantiating 1 Answer

More realistic physics on child collisions 2D 0 Answers

Bullet hit the collider of a child object 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