Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope jiggle after sudden animation position change of handle constraints
#1
I have an animated device which has a rope between two animated elements.
I used the Handle constraint setup on the first and last particle. (works very nicely)

We have many timelines driving this devices animations.
The issue is, that the elements jump positions between the timelines.
So the rope suddenly gets a new position and of course it jumps like crazy to settle down. (impressively robust though!)

I have several ideas to workaround this:
  1. create many ropes - for each timeline one, with a new emitter curve and initialized rest pose, which we than activate per timeline.
    so it starts with at least a somewhat correct pose.
    downside is have have to manually create each curve, create new handle constraints and move them under the two elements.
  2. somehow store initial poses for each timeline and feed this at the beginning of each timeline into one rope as initial pose.
Do you have any other ideas?

I am not a coder but we have some here in the office (but they are extremely busy right now, so as soon as I know which way is possible, I would bother them with that issue Guiño


If you need more clarification please let me know. I can upload a video and share it via PM (since it cant be shown publicly)

Thank you very much!

Best,
Philipp
Reply
#2
(28-08-2019, 11:38 AM)pixhellmann Wrote: I have an animated device which has a rope between two animated elements.
I used the Handle constraint setup on the first and last particle. (works very nicely)

We have many timelines driving this devices animations.
The issue is, that the elements jump positions between the timelines.
So the rope suddenly gets a new position and of course it jumps like crazy to settle down. (impressively robust though!)

I have several ideas to workaround this:
  1. create many ropes - for each timeline one, with a new emitter curve and initialized rest pose, which we than activate per timeline.
    so it starts with at least a somewhat correct pose.
    downside is have have to manually create each curve, create new handle constraints and move them under the two elements.
  2. somehow store initial poses for each timeline and feed this at the beginning of each timeline into one rope as initial pose.
Do you have any other ideas?

I am not a coder but we have some here in the office (but they are extremely busy right now, so as soon as I know which way is possible, I would bother them with that issue Guiño


If you need more clarification please let me know. I can upload a video and share it via PM (since it cant be shown publicly)

Thank you very much!

Best,
Philipp

Hi there!

You need to write a little bit of code for this. When "teleporting" the rope (which is essentially what the timeline is doing), you need to deactivate the rope right before the timeline jumps to a new playback position, and re-activate it after the first FixedUpdate() after the timeline has jumped (you can use WaitForFixedUpdate for this). This ensures the rope does not feel the abrupt change in position.

In Obi/SampleScenes/SampleResources/Scripts/ObiActorTeleport.cs you have an example of this, that will teleport any actor to a random position inside a sphere when you press any key. Pasting it here for convenience:

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

public class ObiActorTeleport : MonoBehaviour {

   public ObiActor actor;

       void Update () {
       if (Input.anyKeyDown)
           StartCoroutine(Teleport());
       }

   IEnumerator Teleport(){

       actor.enabled = false;

       // change position here. I'm just teleporting the actor somewhere inside a sphere of radius 2:
       actor.transform.position = UnityEngine.Random.insideUnitSphere * 2;

       yield return new WaitForFixedUpdate();
       actor.enabled = true;

   }
}
Reply
#3
(29-08-2019, 08:02 AM)josemendez Wrote: Hi there!

You need to write a little bit of code for this. When "teleporting" the rope (which is essentially what the timeline is doing), you need to deactivate the rope right before the timeline jumps to a new playback position, and re-activate it after the first FixedUpdate() after the timeline has jumped (you can use WaitForFixedUpdate for this). This ensures the rope does not feel the abrupt change in position.

In Obi/SampleScenes/SampleResources/Scripts/ObiActorTeleport.cs you have an example of this, that will teleport any actor to a random position inside a sphere when you press any key. Pasting it here for convenience:

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

public class ObiActorTeleport : MonoBehaviour {

   public ObiActor actor;

       void Update () {
       if (Input.anyKeyDown)
           StartCoroutine(Teleport());
       }

   IEnumerator Teleport(){

       actor.enabled = false;

       // change position here. I'm just teleporting the actor somewhere inside a sphere of radius 2:
       actor.transform.position = UnityEngine.Random.insideUnitSphere * 2;

       yield return new WaitForFixedUpdate();
       actor.enabled = true;

   }
}

Great, thanks. 
But this assumes that the rope is not changing its initial form, is it?
In our case the rope needs to have different starting poses. sometimes the elements are very far away, sometimes close to each other. 
Is it possible to feed different restposes per timeline to the rope?
Reply
#4
(29-08-2019, 08:57 AM)pixhellmann Wrote: Great, thanks. 
But this assumes that the rope is not changing its initial form, is it?
In our case the rope needs to have different starting poses. sometimes the elements are very far away, sometimes close to each other. 
Is it possible to feed different restposes per timeline to the rope?

Hi,

Obi only stores one rest state per rope. If you need to reset the rope state every time a timeline restarts, you will have to write a custom system to store your own rest per-particle positions and velocities per each timeline, and set them when the timeline starts playback.

Check out the particle API reference to learn how to get/set particle properties:
http://obi.virtualmethodstudio.com/tutor...icles.html
Reply