NavMeshAgent/parenting causing stutter on the ragdoll bodyparts

264 views
Skip to first unread message

jazzj2

unread,
Jul 10, 2016, 8:49:08 AM7/10/16
to Developer Support
i'm trying to recreate my boxing project 
the Ragdoll bodyparts always seem to update their position with a slight delay, making them seem like they're stuttering in space
i'm noticing that if i disable the NavMeshAgent the stutter stops
THEN i noticed that the issue was because both my animated and ragdoll bodies were parented to a single gameobject, which had the NavMeshAgent component
when i moved the navmeshagent component onto the animated body, the stutter on the bodyparts was gone
however, i'm still getting the same stutter issue while the navmeshagent is moving. if it stops, everything is going smoothly, but when i start moving in any direction, the bodyparts are stuttering
i've attached a video of the issue here. framerate is around 60 the entire time
i've only got 3 scripts in the project - one for camera controls, one for animation controls on the boxer and one that inherits it to control the player's movement
last time i asked about a similar thing, you suggested that it might be me changing the speed on some of the animations. i'm sure that's not the issue now, seeing as things do seem to work correctly when the navmeshagent isn't moving. and in this project i'm not changing animation speed by code anywhere. only set the animations in the animator controller to be at 0.75 speed
i'm sure it's something to do with the navmesh and not my scripts. i've tried commenting out stuff like layer weight changing or the navmesh destination setting, and i was still getting the same results
i'm using Unity 5.4.0b19 (64-bit) and ragdoll workshop 3.0.0f1. i haven't recently tried in older versions of unity, but i'm sure i was getting similar issues before as well

stutteronmovement.mp4

jazzj2

unread,
Jul 10, 2016, 8:50:38 AM7/10/16
to Developer Support
also download link for a demo, since apparently it's too big to just post the file here
controls are WASD to move, Q/E/Mouse buttons to attack

Developer Support

unread,
Jul 10, 2016, 3:00:49 PM7/10/16
to Developer Support
Okay so while I can't really see what you're talking about in the video, I think I am seeing it in the build. Is there any possibility you could get me a copy of your project folder so I could look at how everything is set up? You could send it to bu...@candlelightinteractive.com

Thanks!
Message has been deleted

Developer Support

unread,
Jul 10, 2016, 8:28:37 PM7/10/16
to Developer Support
Thanks for sharing the link! Is it possible you could send a link to a zipped up complete project to bu...@candlelightinteractive.com? In the public link you shared, for example, there are no project settings or similar, which may affect my ability to reproduce results.

jazzj2

unread,
Jul 11, 2016, 3:17:38 AM7/11/16
to Developer Support
huh? that was the complete project
i took the project folder and archived it
i don't think i've touched the project settings aside from creating one extra layer

Developer Support

unread,
Jul 11, 2016, 10:47:37 AM7/11/16
to Developer Support
Hmmm well the only thing contained in the .rar I opened was the Assets folder (so, e.g., no ProjectSettings folder). While the Assets folder contains the boxer model/animations/materials/texture and two scripts, it does not contain any prefabs or scenes either. I really need something that I can basically just open and press play and see the problem. Otherwise there's no real guarantee I'm going to set up a test case that matches your setup. Basically the fewer instructions I have to follow to see the problem, the more likely I can reproduce it and faster I can figure it out :)
Message has been deleted

Developer Support

unread,
Jul 11, 2016, 12:40:43 PM7/11/16
to Developer Support
Ah thanks I retried the .rar you had linked and I'm guessing the first time there was just some problem with my unpacking software, as it seems to have worked this time. I'll take a look and let you know if I find anything out. That said, I also deleted the posts since they contained public links that contain Ragdoll Workshop, which is why I generally prefer that links or files be sent to bu...@candlelightinteractive.com :)

Developer Support

unread,
Jul 13, 2016, 3:47:00 PM7/13/16
to Developer Support
After looking into this a bit, assuming I'm seeing the same thing you're describing, my take is that the problem is simply that the NavMeshAgent's update frequency is lower than your render loop's frame rate. Basically, NavMeshAgent's position gets updated during the fixed time step. If your fixed time step is something like 50Hz (e.g., 0.02) and your render loop is consistently higher (e.g., 60+ fps) then there are some frames that get rendered in succession where the agent's position hasn't changed because there hasn't been another fixed update loop since the last render. Basically, your camera keeps moving and the character keeps pausing every so many frames, which causes the stutter. I'd recommend dealing with it in one of two ways:
  1. Decrease your fixed time step (e.g., potentially 0.01 or better). If your game is very physical in nature and doesn't have a lot of characters at once, this may not be a bad option anyway.
  2. Handle character movement with something that is interpolated during the render loop instead of NavMeshAgent (e.g., CharacterController or Rigidbody). If you don't use pathfinding or obstacle avoidance or things like that, you may want to do this anyway.
In looking at your project, I also noticed a couple other things:
  • If you want to keep your Animator Controller more or less as you have it, I would recommend slightly decreasing the weight of the layer with your full body ragdoll mask. Right now it is 0.1, which means the characters will, at best, operate with a maximum strength of 0.9, which is probably a bit floppy for sober fighting :) A value of e.g., 0.00001 or something will be much snappier for characters at full strength, and you could change it as the characters take more damage so they recover more slowly. That said, I'd probably instead handle it with something like the Max Strength property on the individual body parts and set up a full-body ragdoll state on one of the other controller layers (assuming you want and have animations for getting up from full-body ragdoll).
  • You have enabled Skinned Mesh Renderers in the animated hierarchy with invisible materials. Is this just to prevent animation culling? If so, it may be a better idea to remove/disable these Skinned Mesh Renderers and instead change the culling mode on your Animator components (e.g., Always Animate). It also may not be a bad idea to enable Update When Offscreen for the Skinned Mesh Renderers in your ragdoll hierarchy.
  • It looks like your characters have the default 3DS Max Biped hierarchy. Although I didn't see any problems when running the game, it is important to note that the default Biped hierarchy does not have the recommended topology (e.g., it has the legs as children of the first spine node instead of children of the pelvis; the collar bones are children of the neck instead of children of the rib cage). If you ever run across a situation where you're getting weird results (e.g., arms or legs look kind of broken off) it may be a consequence of this and I would love to make sure I get a bug report :)

jazzj2

unread,
Jul 13, 2016, 4:32:09 PM7/13/16
to Developer Support
actually i have been getting a lot of cases where the forearm ends up bending backwards
but that might be happening because i tampered with the joint settings, i think i set the Z angular limit to 90 or something, since i wanted the forearms to be pointing towards the ground when they're in a ragdoll state and the rest of the character is still standing up

i'll mess around with the weights, the boxers did look like they're made of jelly a bit too much at times

i have considered not using the navmesh, since in most cases the fighting areas are gonna be simple rectangular spots, and there shouldn't be any obstacles aside from other enemies. at most i can probably implement A*. i usually stray from it since i have no idea how to do vertical pathfinding with it, but for my case i probably won't need that

i made an invisible material since i didn't realize there was a better way to keep the character animated, i'll change it to always cull

i also wanted to ask, is there any way i can set how much the ragdoll can react to collision, other than layers and those curve settings?
i currently have a Punch class that stores how much damage each hit should do, and i'd like to make the ragdolls react mostly to that, not the actual physics. 
but messing with the layers for this seems like a very roundabout way of doing it

jazzj2

unread,
Jul 13, 2016, 4:37:23 PM7/13/16
to Developer Support
also just tried things, changing the timestep to 0.01 fixed everything, thanks.
i'll probably stick with navmesh then

Developer Support

unread,
Jul 13, 2016, 6:10:49 PM7/13/16
to Developer Support
Glad to hear changing the time step seems to work for you :)

As for your other question: You could go about this a couple of ways. Some things that occur to me off the top of my head:
  1. Subclass RagdollPart and override OnCollisionEnter() and/or TryAddImpactAtPoint(). For example, you could record information about the type of hit in the collision event and potentially scale the impulse processed by the latter method appropriately
  2. Subscribe to RagdollPart.OnCollisionEnterEvent and basically implement your own temporary modification to RagdollPart.MaxStrength similar to how the impact curves work (e.g., you have a coroutine that decreases it based on the hit type and then ticks it back up). You'd want to also somehow affect nearby parts, but I haven't made any APIs to do this public yet (e.g., RagdollPart.ReduceStrength()).
I'll think about some other ways to make this more flexible in the future

jazzj2

unread,
Aug 6, 2016, 6:20:50 AM8/6/16
to Developer Support
hi, i've got another minor issue
i've use the auto detection in order to set up the ragdolls, but some of the joints are a bit weird
the right hand's thumb should be pointing towards the head, in the idle animation
and both forearms are clipping too much through the upperarms
i'm not exactly sure which paramaters in the joints to change, mostly everything just fucks up the joint entirely
i also tried rotating the ragdoll's forearm transforms, which fixed things during my idle animation, but makes other animations weird, as you can see in the third picture
ebf7731c70a3b0a9436a1e0001aac71a.png
d4ea7c72853df4139c9aef191088b07d.png
fb7f1bb66d2ae0d495c7aab4021449d7.png

jazzj2

unread,
Aug 6, 2016, 6:55:43 AM8/6/16
to Developer Support
oh nevermind, the issue is that i was using the auto detection on a character that isn't in a t-pose
Reply all
Reply to author
Forward
0 new messages