Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by impguard · Oct 01, 2016 at 09:59 PM · 2dgravityplatformjerky

Collisions and Jerkiness Unity 2D

This must be a solved problem that I am failing to GoogleFu.

I'm learning Unity and building a simple model for a 2D puzzle game using the Unity's physics engine. Right now, I'm having a problem with collisions being/looking precise.

Case 1

When my player object, a black square, collides into the walls of the arena (four rectangles forming a square arena), the player tends to penetrate slightly before bouncing out. It's slight, and I've played with the "min penetration settings" but it's noticeable and quite annoying.

Case 2

I've been playing with the 2D Slider Joint to create a platform that can slide along an axis. When my player collides into this platform along an axis that the slider joint shouldn't move in, the joint/platform bounces.

For example, if my player is falling from top to bottom along the Y-axis, and the platform is constrained to move along the X-axis only, it'll slightly shift along the Y-axis upon collision. What's worse, it won't bounce back and will continue to play out in its shifted position. When the player object falls off (say, gravity shifts to push it from bottom to top), the platform will jump back to its original position.

Again, pretty aggravating.

Question

Are there any ways around this? Should I just be blowing up the size of my arena/player character so that these effects are less noticeable? Perhaps I'm playing with small units (My player character is 0.5 units large) so the effects are pronounced?

Or is this just something flawed with Physics systems or Unity's physics system? In this case I'll have to create my own physics system/movement system and that just seems really unfortunate for such simple cases.

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 conman79 · Oct 01, 2016 at 10:36 PM

Case1 is a limitation of the physics system. Physics calculations are intensive and so are limited by processing power of your system. The default physics calculation cycle in unity is 0.02 seconds, or 50 fps. Depending on the amount of physics interactions in your game and your target platform you can increase this cycle rate in Project Settings > Time > Fixed Timestep for better results. For example setting it to 0.01 will double the physics fps to 100 which will look better but also double the processing overhead. This should be fine for relatively simple physics based games.

Case2: Have you set "Freeze Position" on the Y axis in the Contstraints of your platform rigidbody? This should solve that problem. Probably should freeze Z rotation too.

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 impguard · Oct 02, 2016 at 08:36 PM 0
Share

The former makes sense but not at the scale I'm at. 50 fps should be more than enough to handle this jittering. The box is making it half a unit into the wall before bouncing out sometimes. I've worked with physics systems and this type of behavior is more pro$$anonymous$$ent in shooters when projectiles are moving too fast.

I set the freeze position to see if that would affect anything when debugging. It didn't. As far as I'm concerned, I shouldn't "need" to do that. Otherwise, that just invalidates the point of the 2d slider joint. Also, unfortunately, I'm going to need other axes other than X-Y so constraints wouldn't be a permanent solution even if it did work.

avatar image conman79 impguard · Oct 03, 2016 at 01:54 AM 0
Share

Is your camera moving in your game or is it static?

avatar image impguard conman79 · Oct 03, 2016 at 05:57 AM 0
Share

Currently static. The prototype is pretty much as simple as it can be.

There's a player character (black box). There's an arena (four rectangular walls, empty inside). There's a platform (rectangle inside the arena.

I apply a force to all objects inside the arena in one direction, say Y-axis down. The platform has a 2D slider joint component that prohibits it from falling down and being affected by this force. That works great.

As the player character falls, it gains speed but really isn't moving anything fast. When it strikes my platform it pushes it 1/4 a unit down before stopping.

If my character misses the platform (I delete it), it will fall onto the arena wall. About 1/5 times, it clips into it noticeably before bouncing out. Just one or two frames after I adjusted the settings, but enough that anyone would notice and think something glitched.

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

107 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

Related Questions

Help me with gui please (C#) 2 Answers

Child an Object to Another Objects Parent On Collision 1 Answer

Throw Rigibody2D cannon to a 2D target (with gravity), reach in time, how to calculate Addforce ? Please & Thx 0 Answers

Rigidbody2D falls slowly with MovePosition? 1 Answer

Hi thanks in advance , i can't find the error in my code but my character can't stop from going up when i jump onto the platform i made which has a platform effector 2D applied to it 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