Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope static attachment seems to lag behind the moving object it's attached to
#1
You can see what I mean here: https://youtu.be/cMG1YjnYDwM

The rope has an attachment to the character's hand, but it follows a bit behind the char as you move.

Solver is on FixedUpdate, character is being moved through physical forces. Both the character and the rope have interpolate on.

Code for the attachment is here, in case there's something about the initial setup that's causing problems:

Code:
public void AttachParticle(RopeChar ropeChar, int particleIndex)
    {
        attachedRopeChar = ropeChar;

        // Create a new attachment and set it to be attached to the character's hand
        attachment = obiRope.gameObject.AddComponent<ObiParticleAttachment>(); 
        attachment.target = attachedRopeChar.attachTransform;
                   
        // Handle gameplay of attached char (swings from hinge, the rope is just visual and used for collision detection)
        attachedRopeChar.AttachToRope(this);

        // Move the collided particle to the char's hand pos
        UnityEngine.Vector3 relativePlayerPos = attachedRopeChar.attachTransform.position - solver.transform.position;
        solver.positions.SetVector3(particleIndex, relativePlayerPos);
   
        // Create a new particle group and assign it the particle that you collided with
        ObiSolver.ParticleInActor particleInActor = solver.particleToActor[particleIndex];
       
        ObiParticleGroup group = ScriptableObject.CreateInstance<ObiParticleGroup>();
        group.particleIndices.Add(particleInActor.indexInActor); // index of the particle in the actor
        attachment.particleGroup = group;
    }
Reply
#2
(25-07-2024, 02:26 PM)ShawnF Wrote: You can see what I mean here: https://youtu.be/cMG1YjnYDwM

The rope has an attachment to the character's hand, but it follows a bit behind the char as you move.

Solver is on FixedUpdate, character is being moved through physical forces. Both the character and the rope have interpolate on.

Code for the attachment is here, in case there's something about the initial setup that's causing problems:

Code:
public void AttachParticle(RopeChar ropeChar, int particleIndex)
    {
        attachedRopeChar = ropeChar;

        // Create a new attachment and set it to be attached to the character's hand
        attachment = obiRope.gameObject.AddComponent<ObiParticleAttachment>(); 
        attachment.target = attachedRopeChar.attachTransform;
                   
        // Handle gameplay of attached char (swings from hinge, the rope is just visual and used for collision detection)
        attachedRopeChar.AttachToRope(this);

        // Move the collided particle to the char's hand pos
        UnityEngine.Vector3 relativePlayerPos = attachedRopeChar.attachTransform.position - solver.transform.position;
        solver.positions.SetVector3(particleIndex, relativePlayerPos);
   
        // Create a new particle group and assign it the particle that you collided with
        ObiSolver.ParticleInActor particleInActor = solver.particleToActor[particleIndex];
       
        ObiParticleGroup group = ScriptableObject.CreateInstance<ObiParticleGroup>();
        group.particleIndices.Add(particleInActor.indexInActor); // index of the particle in the actor
        attachment.particleGroup = group;
    }

Hi!

Solver should be using LateFixedUpdater, since you want the rope to use the position of the rigidbody *after* it has moved in FixedUpdate. Otherwise the rope will be one frame behind.

Let me know if I can be of further help,

kind regards
Reply
#3
Thanks for the quick reply - that solved my main issue!

However, I'm getting some weird little pops now at the end of the swing when the movement direction changes. Any thoughts on what might be causing that?
https://youtu.be/Joty-hJeaDY


Btw, I should mention that I put in your changes from this old post in order to add interpolation to the attachment and reduce jitter, which did help a lot, but there's just the above issue remaining: 
http://obi.virtualmethodstudio.com/forum...l#pid13995
Reply
#4
Just wanted to bump this one since I think it fell through the cracks a bit. Any ideas?
Reply