Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 tayloreichhorst · Aug 07, 2015 at 01:59 PM · rigidbody2dphysics2dkinematicinterpolationinterpolate

Interpolation issue, some items not being interpolated correctly.

I have a game in which you break through obstacles and the obstacle parts separate into physics based pieces.

All of the pieces are contained in the parent object, they all have rigidbody2d on them, set as kinematic and no interpolation. Once they break apart, I turn off kinematic and turn on interpolation for smooth movement. This works great right now and the game is running amazingly with a lot of obstacles on screen.

The problem is, when there is a lot of obstacles, and a few of them are broken apart, some of the pieces are very jittery and act as though they are not being interpolated, while some (even from the same parent) are smooth as butter.

I wonder if this is an interpolation restriction, like maybe only a certain number of things are meant to ever be interpolated at a time?

Here is the code I'm using.

 void OnTriggerEnter2D (Collider2D col) {
                    if (col.tag == "Shockwave" && gameObject.tag != "Transition") {
     
                 if (spin != null) {
                     spin.spinning = false;
                 }
     
                 if (!isShard) {
                     obstacleCol.enabled = false;
                     objDespawn.enabled = false;
                     SeparateObject ();
                 } else {
                     obstacleCol.isTrigger = false;
                 }
     
                 worldStats.totalObstaclesDestroyed ++;
             }
     
             if (col.tag == "Blast" && gameObject.tag != "Transition") {
     
                 if (spin != null) {
                     spin.spinning = false;
                 }
     
                 if (!isShard) {
                     obstacleCol.enabled = false;
                     objDespawn.enabled = false;
                     SeparateObject ();
                 } else {
                     obstacleCol.isTrigger = false;
                 }
     
                 worldStats.totalObstaclesDestroyed ++;
             }
     }
 
 
 void SeparateObject ()
     {
         foreach (Transform shard in shards) {
             if (shard.GetComponent<Collider2D> ()) {
                 shard.GetComponent<Collider2D> ().enabled = true;
             }
             
             if (shard.GetComponent<Rigidbody2D> ()) {
                 Rigidbody2D rb = shard.GetComponent<Rigidbody2D> ();
                 rb.isKinematic = false;
                 rb.interpolation = RigidbodyInterpolation2D.Interpolate;
             }
         }
     }





Comment
Add comment · Show 6
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 dsmeathers · Aug 07, 2015 at 07:06 PM 0
Share

How are you moving them, with a script or an animation? If they're kinematic then they're not being updated by the physics.

If you set your time settings to a fixed timestep of 0.0166666 and maximum allowed timestep to 0.01666666 does the problem go away? With those settings you shouldn't need interpolation enabled.

avatar image tayloreichhorst · Aug 07, 2015 at 07:32 PM 0
Share

They are being moved while kinematic is active through their parent, not by physics (maybe i should not even have a rigidbody on them at this point?) The parent is simply moving by transform.position. Once they are separated from the parent (after player hits parent), i turn kinematic off and let physics take over for each part, this is also where I turn on interpolate.

I'll try what you said about the timestep. Will that work if the framerate changes though? $$anonymous$$aybe that is not a big deal since I am getting a pretty s$$anonymous$$dy 60fps.

avatar image dsmeathers · Aug 07, 2015 at 08:33 PM 0
Share

With those settings the game will slow down if the frame rate drops, it'll be like going into slow motion for a bit. It will always be smooth though.

To be honest the jittering is probably due to something other than the interpolation, but it'd be good to rule that out.

avatar image tayloreichhorst · Aug 18, 2015 at 03:00 AM 0
Share

So I came back to this problem after ignoring it for a bit. I still don't have it figured out, but I now am under the impression that it isn't a problem with the Interpolation. I turned interpolation on by default, same problem.

Here is where I am at now, in case anyone is interested... I have a player and obstacles he has to avoid, if they player hits an obstacle, the obstacle separates into pieces that go flying. This works great, when I hit an obstacle, it separates well and interpolation is working as it should. Now, what I also do, is send out a shockwave that hits surrounding obstacles. The same code is applied to these to separate them, but it's the shockwave collider trigger that is setting this in motion. This seems to be where the issue is. Imagine a giant circle around the player turning on for a split second and whatever is in that circle is destroyed. Anything that is destroyed this way, has jittery movement. When I pause the game however, these pieces have all the same properties that a working peice does.

avatar image dsmeathers · Aug 18, 2015 at 02:45 PM 0
Share

Hey Taylor, I think you'll need to post some code to get an answer to this.

Show more comments

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

24 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

Related Questions

[Video] 2D hinge joints not working. 1 Answer

Rigidbody 2D with interpolate = cant rotate object 0 Answers

How do I Spawn an Object on a Seafloor Randomly? 0 Answers

The character velocity changes while the rigidbody is kinematic 1 Answer

Collision2D.relativeVelocity should be 0? 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