Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Move + attach particle sometimes is offset from the intended move position
#1
Hi,

In my game, you can jump on and swing from ropes. When your rope grab collider hits a particle on the rope, I move that particle to a specific position and then create an attachment (triggered when the rope grab collider hits any particle on the rope):

Code:
// Move the collided particle to the char's hand pos
Vector3 relativePlayerPos = attachedRopeChar.attachTransform.position - solver.transform.position;
solver.positions.SetVector3(particleIndex, relativePlayerPos);

// Create a new attachment and set it to be attached to the character's hand
attachment = obiRope.gameObject.AddComponent<ObiParticleAttachment>();
attachment.target = attachedRopeChar.attachTransform;


This USUALLY works, but about 1/4 of the time there's a small offset between the attach point and the location it was supposed to move to. This seems to happen no matter when I move the particle to the hand, even if it's every frame. Here's a video of the normal correct functionality and also how it looks when it's offset:
https://youtu.be/somDPpYDT6o


I haven't figured out a repro for the issue. Strangely, it seems like on a given playthrough, it either works perfectly every time OR it's offset every time for that entire playthrough. It will randomly then be working or not working again on the next playthrough. This makes me think that there's something about the random starting conditions of the game that's causing it - maybe some Obi's LateFixedUpdate somehow gets out of sync with the timing of the game?

Some other info that might help:
- Obi version 6.5.4
- I'm using Fixed Late Updater with 4 substeps
- Initial attachment is triggered by Solver_OnCollision
Reply
#2
Hi,

Since this isn't a constant offset but depends on character speed (offset increases the faster it's swinging) I don't think this has to do with starting conditions or callback order. Looks more like the character is one full frame behind the rope - as if using rigidbody interpolation?

It's really hard to tell without a complete picture of how your system works. Would it be possible for you to share a project that reproduces this, even if it's a stripped down version of your actual project?

(05-12-2024, 07:28 PM)ShawnF Wrote: Obi's LateFixedUpdate somehow gets out of sync with the timing of the game?

LateFixedUpdate is really just Unity's WaitForFixedUpdate, no way for it to get out of sync with everything else in the game.

kind regards
Reply
#3
Oh, I am using rigidbody interpolation on the main character (and interpolate is turned on on the rope). Could that potentially cause this issue? If so, argh... that's a bit tricky. Without it, I get some pretty bad stuttering. Any ideas on a workaround for that?

I did just play around with it a bit. After restarting a few times until it was offset, here's what I found:
- Changing interpolation settings on the player has no effect
- However, if I turn off Interpolate on the rope solver, the rope more or less sticks to the right place, but becomes very stuttery
- On a whim, I switched the backend to Oni and also got slightly different results there. Not sure if that gives any useful information, though.

You can see this here:
https://youtu.be/ILCu33eHWP0


I'm about to sign off for the day, but I'll take a look at giving you access to the project on Monday morning. In the meantime, I thought I'd already post this just in case this was useful. 

Thanks for the help in any case!
Reply