Forum rules - please read before posting.

Player Character Dynamic Joints Lag

Hi,

I've been adding some dynamic joints to my Adventure Creator player character that use physics (Unity's Character Joints/Rigidbodies) to flop around and provide some secondary motion. I'm using them for a ponytail, pouches that I want to bounce around, things like that.

So far so good but it seems that when my player characters walks/runs in the game the translation position of these dynamic joints lags behind the character. When they stop moving it catches them up.

I've checked 'animate physics' checkbox on the character's Animator component but it doesn't seem to improve things much. I've been digging around online and read that anything that utilizes physics are best updated using FixedUpdate( ) rather than Update( ). Does anyone know which update function Adventure Creator uses to move/translate the player character? I thought if this was being done in Update (with the dynamic joints using FixedUpdate) it might be the reason for the lag.

I've been looking at it for a little while so thought I'd post up and see if anyone had any suggestions.

Thanks in advance,

Alex


Comments

  • Welcome to the community, @PolygonTreehouse.

    As this is a very visual problem, seeing some screenshots of the issue would help to understand it.

    The physics system was updated in v1.57 - are you using that?  Rigidbody-based characters will now move (by default) by having forces applied to them in FixedUpdate().  This is the "best practice" way of doing things, and smooth motion can be enabled by adding Interpolation to the Rigidbody.

    If you prefer, you can bypass Rigidbody-based movement altogether, and just rely on transform position changes in Update(), by unchecking Move with Rigidbody? in the character's Inspector.
  • Hey Chris,

    Thanks for that, good to know. I'll update to v1.57 and have a look with your suggestions in mind. If it persists then I'll pull some videos together to illustrate. I'll post back the results either way.

    Cheers,
    Alex


  • Hi,

    I've all updated to the latest AC and have dug in a little deeper and this is what happening. I've created a video to demonstrate and whacked it on Vimeo, you should be able to access it using the following private link, please forgive the placeholder level and animations.


    (any problems accessing the video give me a prod)

    With 'Move with RigidBody' checked her dynamic joints lag behind when she walks. Looking at the video if you pay attention to her bobble-hat and her backpack you will see they are pulled away from her body when she moves. 

    Unchecking 'Move with RigidBody' on the player script removes the lag, hopefully you can see in the video that these dynamic parts are not lagging behind.

    However, It doesn't look like this is a valid solution. When the player goes up a slope (see viddeo) with 'Move with RigidBody' unchecked the dynamic joints break badly, whereas with it checked they work fine, albeit with the lag.

    It seems that enabling 'Move with RigidBody' is important, just wish I could get rid of the lag. I imagine it will be even more apparent when moving at higher speeds, running for example.

    I imagine some of this is getting out of the Adventure Creator remit but thought I'd post my findings as promised.

    Many thanks,
    Alex

    Note: all rigid bodies have interpolate turned on.
  • Is there anything special about the slope other than its orientation?  I wonder what difference root motion would make to things.

    Are any custom scripts involved?  It may be that the Script Execution Order needs to be changed relative to AC's StateHandler script (which handles all of AC's Update calls).
  • Morning!

    Nothing special about the slope, just collision and navmesh. There may be a bit of discrepancy between the navmesh and the collision (the collision is just some roughly rotated/placed cubes at present).

    There is a simple custom script on each of the dynamic joints to apply some of the movement of it's parent joint as a force, but the slope issue (when using 'Move with RigidBody' unchecked) occurs even when these scripts are disabled so it doesn't look like that is the cause.

    I was tempted to try and brute force the translate position of each dynamic joint every frame to eliminate the lag when using 'Move with RigidBody' so might give that a go but it doesn't feel particularly elegant.

    I haven't tried using root motion yet, maybe I'll give that a whirl as well.


    I'll keep on digging, thanks for the suggestions.
    Cheers,
    Alex

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.