Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope jiggle after sudden animation position change of handle constraints
#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


Messages In This Thread
RE: Rope jiggle after sudden animation position change of handle constraints - by pixhellmann - 29-08-2019, 08:57 AM