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 Kiriton-San · Jul 31, 2016 at 09:54 AM · movinggameobjectphysics 2d

Prevent physics shaking

Hi people.. I'm having some problems with physics, my character keeps passing through moving floors/objects.

This (poorly) animation is what I expect:

expectation
As you can see in the animation above, the character keeps nice on the floor. Now the reality is this (not animation, used unity):

reality
Here we have two problems:

1. The character is moving to both sides (and jumping), shouldn happen, since the floor where he is standing is not rotating.

2. The character gets into the floor, sometimes he pass through the floor completely. If I increase the velocity of the rotation, it's almost impossible to make the character stand on the ground.

This is a prototype (thats why the sprites are sh**y).

Code - Rotator.cs

 public class Rotator : MonoBehaviour {
 
     public float DegreesPerSecond = 80.0f;
 
     void Update () {
 
         transform.Rotate(new Vector3(0, 0, Time.deltaTime * DegreesPerSecond));
         
         // The grund where the player will stand...
         Transform block = transform.FindChild("Block");
 
         if (block != null) {
             block.localRotation = Quaternion.Euler(-transform.rotation.eulerAngles);
         }
     }
 }

Structure alt text

The rotator is using Polygon Collider, but that Block child (where the player will be) is using Box Collider 2D. Tried to switch from Polygon to Box Collider and still same issues.

I think the player script is irrelevant, since I'm only moving the player to prevent him fall off the screen. I can disable the player script, the issues listed above will happen, the difference is that the character will fall off, so I don't think the player script is the problem.

I bet that this will happen on every moving object/ground, so, there's a way to fix this?

PS. Newbie on unity and game developing.
PS²: English is not my native language.
PS³: Using Unity 5.3 x64.

structure.png (19.6 kB)
Comment
Add comment · Show 1
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 ScaniX · Jul 31, 2016 at 10:08 AM 1
Share

I was struggling with this as well in a 3D game. But actually - if you think about it for a $$anonymous$$ute - the lower one is more physically correct than the first one where the character is kinda glued to the platform and ignoring inertia.

In the end I don't think you can solve this by using physics. You might have to parent / unparent the character to the platform whenever it touches it or have a script that directly moves the character by the same delta that the platform moved in the meantime (which is my approach).

There are some other posts with solutions to this on here if you search for "platform" or stuff like this.

By the way: Nice post! :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Dragging object with a mouse from one point to another point, Have a big problem 1 Answer

How to make an 2d object jump from A point to B point? 0 Answers

how should i move a vehicle correctly in unity,what kind of rigidbody physics should i add to move a vehicle ?? 1 Answer

How to calculate angular velocity after a collision? 0 Answers

percentage bar parented to a moving rotating object 2 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