No animatorOverride for non-humanoid characters

Hi community,

Probably a simple answer but im missing it.
In the RPG course, how would I go about having no animation override controller on, say, non-humanoid characters. So for example, a spider enemy that has its own animations. I dont want to be overriding the animations that came with the asset (i just changed the triggers), but when the game starts, the defaultAnimationOverrideController from WeaponConfig takes over and the spider does not animate correctly. Its interesting that I also needed to set the LeftHand and RightHand transform still.

The spider enemy will have no weapons attached, but needs the fighter script, so it wont need any overrideControllers at all.

What would be agood work around for this?

Cheers

1 Like

Hi!

I took the RPG course a few years ago, so I don’t exactly remember how Sam structured the code, but from what you are saying, you’ll need to create a new ‘Animator Controller’ specifically for the spider, as for the script, well… that would be the biggest issue, the easiest way to do this is to create a script to handle the spider’s behaviour, but, if you are planning on creating multiple enemies, then you’ll end up with way too many scripts, so you’ll have to structure your code to prevent that from happening, like having a whole non-humanoid enemy inheritance hierarchy, just like how Sam did that for humanoid characters.

Hope this helps, but if it doesn’t, maybe @Brian_Trotter can help you.

The trick here is to create unique weapons for the non-humanoid characters. Now the spider itself doesn’t actually have a weapon model (because if the model maker did their job, there should be two nice pointy fangs, a bunch of nasty legs and for projectiles, if you’re really silly about it, a spinnerette.
Simply create a WeaponConfig for the Spider’s weapon, and an empty GameObject (no model, towards the end of the course, the Weapon will hold sound effects, so you can put that Weapon script on it when you get there). Put the Spider’s animator in the Spider’s Animator override (or I may be forgetting something, you might need to create a blank override for the Spider’s animator.

Hey guys,

Thanks for the helps and the tips. I cant for the life of me figure it out. The spider is just not animating. I have tried all the suggestion you have pointed out. @Brian_Trotter is there a way for me to share the spider asset I have with you so you can easily see what im doing wrong?

Or what can I screenshot in here to give you an understanding of how the model and animations are built so you can point me in the right direction.

Starting to feel really stupid as im sure its a simple thing that I just dont understand.

Cheers

Take a screenshot of the inspector for your Spider’s Animator (the component on the Spider), the Fighter, and the Spider’s WeaponConfig scriptable Object.

SpiderAnimator
SpiderFighter

All of this looks correct. Does your Spider’s animator have the same Parameters (case matters) and conditions as the regular characters?
While the animations may be different, the trigger and speed parameter names need to match.

Hey Brian,

Thanks for your response. Yes I set all the triggers to the same as the course. I think its the model im using. I have deleted in from my project and re-imported it so that it is back to its original state.

I will report back if I can get it to work or not.

Cheers

Hi community,

Update from my previous post: I have managed to recreate the animationController for the spider and it animates as intended. But now i’ve noticed that the model keeps “snapping” back when its in the walk animation. From testing it seems that the navmeshagent is slower than then model, and so the model snaps back to the navmeshagent.

Is there a way to stop this from happening without removing any components? I thought about changing the navmeshagent settings to be shorter and fatter, but apparently its not possible to change navmeshagent radius and height in the inspector. Or would it need to be a programmatic fix to slow the model down?

Cheers

What’s likely happening is that the animation includes motion, which you’ll want to remove.

Here’s an example spider animation from InfinityPBR

So this animation has root motion animation of 4.4314 in the zed axis, which means that if you’re using the animation with root enabled, it will physically more the character 4.4314 units from the beginning of the animation to the end. Make a NOTE of this ending value in your animation, because you’re going to want to use that to match the animation speed to the animation when you’re adjusting.
Now for the fun part…

Right click on that z value and select Remove Key.
That’s it, the motion will be stripped from the animation and the physical model will stay with the NavMeshAgent.

Hey Brian,

Thank you for your reply.
I have done that but it had no effect.
The animations were read-only, so i had to make a copy. Deleted the root motion. Made sure I was using the copy, not the original. Still jarring and snapping back.
I tried using loop pose and loop pose setting. I even tried different animations (there is one called walkSlowInPlace) but it still snaps.
Im contemplating reaching out to the developer to ask.

There was no root as described in yours, so i deleted everything that could be considered as a root motion.

Not sure what else to try now.

Cheers

Yes, you definitely have to make a copy, as most are distributed as .fbx files that can’t be easily edited.
Paste a screenshot of the first three sets of animation keys expanded out and we’ll take a look.

Hey Brian,

Here it is. I deleted both of the root: position and the spiderhub : position keyframes and it was still studdering (the picture is of the read-only animation). I even tried changing the root node in the animation settings, and baking into the pose. Still studders.

I also made sure that the speed of the navmesh matched the speed of the deleted root motion keyframes.

I appreciate your help.

Alex, thank you sir. Ive learnt so much through the 4 courses of the series, and still learning to this day. I would consider myself a beginner - intermediate programmer, so alot of concepts take me alot longer to understand than others. But perseverance is key.

Cheers

Sometimes Unity gets… confused… and interprets a 0 to 0 value to have a curve… click in the middle at say 15 and see if root: Position Position.z is still zero.
If it’s not, right click on Position.z and select Remove Key.

Hey Brian,

Thank you for your reply. The middle node was still 15.
I noticed that the Sipderhub:position Position.x goes from like -3 to +0.1 and jumps around like that, but I tried testing by deleting those nodes and it didnt make a difference. Is there a way to slow the animation down? Like change the fram rate? Because when I speed variable in the navmeshagent component the studdering is less noticeable, but then the animations are way to fast and the spider looks like its ice-skating.

What is another thing I can check? Im waiting on a response from the developer of the asset, but nothing yet. Im working on other parts of the game as I go, and I work a fulltime job also, but rest assured I am not giving up on this bug yet.

Cheers

You can adjust the animation’s speed in the blend tree inspector (or if you’re just running the animation without blending, there should be a parameter in the Animator when you click on the state and look at the inspector).
It’s looking more and more like you’ll need the developer to make an “in place” animation for you.

One last thing, and I’m sure you’ve done this already, but I have to point it out because I noticed the clip you pasted is (Read-Only), which means it’s the one still inside the FBX.
Be sure to Duplicate the one inside the FBX file which will create a new anim file in the same directory (but not buried in the FBX). That one won’t be read only, and you can edit it. Finally (and I’ve done this many times, so it’s why I mention), don’t forget to switch to the copied animation in the Animator. I like to rename the animation to something like “Spider Walk Fixed” to be sure.

Hey Brian,

Yes already doing all those steps you mentioned

  • Copied the animation file so I can edit it

  • Switched the animation files in the animator blend tree to the edited ones

There are actually already in-place animations included with the asset but I am getting the same snapping back behaviour even when using an in-place animation (that definately walks in place when the animation is just played, not in the game scene).

Could there be a conflict between components? The navmeshagent and the animatorcontroller for example, where both are trying to do the same thing at competing times (like a race condition but for animations)?

I will look more detailed at the in-place animations and also at the animation speed.

Cheers

If the animations are in place, then the AnimatorController is doing nothing with regard to the main transform. No conflict is possible between them.

It did occur to me, from this description that it’s possible this is a blending issue. With humanoids, it’s generally easy enough to blend from a relatively static idle pose to a walk, but if the poses are too opposed, they don’t blend well.

This could definitely be the case with the spider animation as well, if the idle and the walk aren’t very similar.

Try replacing the blend tree (with idle and walk in it) with a discrete idle state and walk state, with the transition condition simply being the speed being greater or lower than .05f.

Hey Brian,

Yeah I tried that also. I have tried fiddling with the animation speed, the navmesh speed, the apply root motion options, different animations, ive tried using the spider as a minion. I cant seem to get it to stop jarring and jumping back to meet the navmesh. Im lost on this one unfortunately. I couldnt find anything on google about it either, no reply from the developer yet either.

Cheers

Nevermind, I figured it out. I recreated a new spiderDefaultAnimationOverride, as for some reason the animatorcontroller was getting overriden by an overridecontroller, and that overrider controller (which I created and named spiderOverrideController) did not have spider animations correctly set.

TLDR: The spider was trying to override humanoid animations with humanoid animations, and blend them in a blend tree with spider animations.

So you were correct Brian, it was a blending issue. Thank you for your patience. On to the next problem (sic. feature). lol

Cheers

Privacy & Terms