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 UltimateWalrus · Jul 19, 2014 at 02:48 AM · collisioncollision detectionplatformer

Physics-free collision problems

I could really use advice on how to handle collision detection when making polished platformer-style controls within Unity. Normally I prefer to figure things out on my own but I'm at my wit's end.

I have implemented a physics-free movement, using a non-Kinematic RigidBody with a cylinder-shaped mesh collider parented to it. As far as I know I cannot use the Character Controller as a capsule-shaped collision bound leads to very unsatisfying handling on the edge of platforms, ramps, etc., so it's unacceptable. I need it to be a cylinder.

I handle all movement logic in my own code, and at the end I move the object using rigidbody.MovePosition( pos ). I set rigidbody.velocity to 0 every FixedUpdate as I don't want any physics simulation to happen. After this, the object gets pushed out of whatever terrain it may intersect. I detect the ground by testing the normal in OnCollisionStay.

This seems to work OK for very low player speeds. However, when the object moves even a little fast, it clips through walls. Setting "Interpolate" and "Continuous Dynamic" on the RigidBody seem to do nothing. It looks like rigidBody.MovePosition either does not honor interpolated collisions, or the Unity programmers chickened out of coding mesh collider vs. mesh collider interpolation. Adding a capsule collider to my collision bounds doesn't seem to help, though.

Common practice seems to be setting rigidbody's velocity or applying force to it, and try to trick Unity's physics simulation into handling the collision. This seems to fix the wall problem but leads to other problems. There seems to be a one-frame lag because applying velocity to rigidbody only affects the [i]next[/i] frame, not the [i]current[/i] one. It also seems to affect the way collisions are detected in a way that causes glitchy, erratic behavior when interacting with colliders besides the terrain, likely attributable to the lag.

As a last-ditch effort I would jettison Unity's pushout code and try to do it myself by feeling around using RigidBody.SweepTest (which I could foresee causing performance problems). However, frustratingly, Unity's documentation states that it only works with primitive collision types.

It really looks like Unity is intended for physics-based games only, but not every designer wants their game to be a laggy, slippery kludge-fest. I need "fake" physics. I really think/hope this problem must have been solved simply, dozens of times, and I just haven't been doing the right Google searches.

Any help with this would be vastly appreciated. I'm this close to the ironic, degrading task of manually coding mesh vs. mesh intersect detection for a game engine I paid thousands for.

Comment
Add comment · Show 2
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 Saer · Jul 19, 2014 at 05:10 AM 0
Share

Have you tried lowering the $$anonymous$$inimum Penetration for Penalty in Edit -> Physics?

avatar image UltimateWalrus · Jul 19, 2014 at 06:44 PM 0
Share

That doesn't seem to have any effect, but thanks for your response.

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

23 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

Related Questions

NavMesh Collision Detection? 0 Answers

Collision Dection on Tigger Enter 1 Answer

Last collision 1 Answer

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

Why does my OnCollisionEnter2D not work? 3 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