So why **do** the enemies do the "stress squat"?

When we change the enemy from being a model to being a copy of the ThirdPersonCharacter prefab, they start doing a goofy leg-dangly squat as they hover above the ground. That behavior seems to disappear without comments in later videos.

I know it doesn’t matter that much sense the enemies are just placeholders that will be replaced later, but how do you make this go away?

I thought I had fixed this by unchecking the Animator component on the Enemy prefab. However, after upgrading from Unity 5.5 to 5.6, the stress squat behavior has returned.

There are several issues with the player movement. The stress squat / invisible horse / invisible motorbike issue can be resolved with code changes, but as the code gets ripped out in the later lectures there isn’t a lot of point changing it.

There is a very short raycast which eminates from the bottom of the model. The length of this is what is changed when you set the Ground Check Distance setting, but this doesn’t actually resolve the issue it merely increases the tolerance more before the same problem occurs again.

In the Unity documentation it mentions, fairly subtly, that a raycast will not report back on a collider if it it’s origin is inside one. The code for the ThirdPersonCharacter sets the origin at 0.1 up from the bottom of the model. If this happens to be inside another collider the logic effective!y says “oh, I must be falling then”, and the falling animation is triggered, and doesn’t change.

As the code for jumping etc is fully removed later this does resolve this issue also.

Another issue was caused by only the Move method being set to vector zero, whilst this would suggest the character will not move, the animation state continues to receive updates and the animation itself actually moves the model.

This can also be corrected with code changes to not only say “don’t move” but also to set the relevant state of animation.

Finally, a third issue I have seen is the spinning/twitching when moving issue, this seems to effect people seemingly randomly but if you turn on stats when/if you experience the you may notice that the FPS have dropped right down. In the lecture Rick noticed this after adding the water, but it was in fact the copious quantity of trees that were added to the scene without changing the setting to configure the distance before the 3d trees are automatically changed to billboards. By default this is set to 500, but with that many trees it may need to be lowered for less powerful machines. Using Rick’s scene I needed to change this to 10 on my laptop before the FPS increased significantly, and in doing so the character no longer appeared to spin/twitch when moving.

I hope the above is of use :slight_smile:

Thanks, Rob! The basic root of the problem seems to be having enemies that are not scaled to 1,1,1. Your information about raycasts explains why a mis-scaled Ethan will stress squat and how to go about fixing it, but the quicker fix for me was to just set the scaling back to 1,1,1, which becomes necessary for the animations to work properly (probably for the exact same reasons) in later videos.

1 Like

I should add also then that I was experiencing this with the hero farmboy model also, not only Ethan.

Privacy & Terms