Match Animation To Movement Lecture

Any questions regarding this lecture?

Hi Rick,

my UpdateAnimator function is slightly different to your approach. But it seems to work perfect. Is this an alternative way or will I run into problems later on?

Thanks,
Andy

    private void UpdateAnimator() {
        Animator animator = GetComponent<Animator>();
        Vector3 velocity = GetComponent<NavMeshAgent>().velocity;
        animator.SetFloat("forwardSpeed", velocity.magnitude);
    }
2 Likes

Stick with it for now Andy, as we make changes and updates to this class things may not work, but thats the nature of the beast, we are constantly reshaping our code as we go.

1 Like

Hi yes I have a question. Slightly off topic but still regarding animation.

I am very interested in eventually making my own assets for the game, and I was wondering if I bought the animation pack, with animations and avatar(the polygon one), is it then possible to connect the animations to any model mesh as long as it is rigged up?

I am a little bit hazy with the animator, which I am looking into to getting a better understanding, unity am sort of new to, and I have a lot of experience in coding in general, I am fairly new to C# but my experience in code has meant I have been picking it up very quickly, I am saying this because I had a little experiment with another model but didn’t get very far, I am still looking into this one, thank you.

Hi guys,
I have a trouble understanding “localVelocity” and “transform.InverseTransformDirection()”.
I tried the link to the unity docs, buts its only a couple of lines in there.
Anyone knows what is it about?
Thanks

I am having issues with the forwardSpeed. I am using the latest 2019 version of Unity. When I change the blend tree’s base layer to forwardSpeed it does not change the parameter like it does in your video. And then when I do it manually it says that it is not found still, and makes my character fall halfway into the world. Any help would be greatly appreciated.

Everything works perfectly, i had some issues with the forwardSpeed cause i rename the component and dont the parameter layer.

Also if adding a component “Animator” to the player and character, the character component override the player animations and never walk so i disable it.

1 Like

SOLVED
Hey, I am using animations that I purchased on the Unity Asset Store and am running in to an issue with the animations where they are calling events everywhere using FootR and FootL. I an getting the following error(s)

‘Player’ AnimationEvent ‘FootR’ has no receiver! Are you missing a component?
‘Player’ AnimationEvent ‘FootL’ has no receiver! Are you missing a component?

whenever it switches between animations. The animations are read-only, so I can’t change or delete the events. Has anyone found a way to get past this or do I really have to find new animations? If I can create a variable somewhere in a script or something that at least can bypass this error, at this point, that would be acceptable.

I am hoping someone has some sort of work-around for this. Currently, if I turn off pausing on errors in the console, it works fine. Nothing crashes, I just get a log of errors. Unfortunately, it means if I have other errors in the future, it won’t pause it for me then. And it’s a lame way to bypass a dumb error.

The animation pack I am using is RPG Character Mecanim Animation Pack. It was kind of expensive to be having these issues, and in case this user’s input about the animations helps anyone help me with this issue:

On the last page of the reviews, a user ‘mangax’ posted a review complaining about the same issue:

Great Asset with continuous Updates! But!!

[Updated] i really like this asset, i updated the animations to latest version… but i was annoyed a lot that now many events included everywhere!

i really don’t want these events to be fired… now the game on play mode on always gets paused showing an error whenever there is a function call!

Can you please remove these from future updates?

or at least make them all use single function call like “AnimationClipEvent(string val)” so now you can pass FootR and FootL as strings…instead of each having different function call!

-Any input is helpful at this point, so thanks for taking the time :slight_smile:

Would you be able to make empty methods taking the animation event to avoid the error? If you comment out the Hit() event we use for the attack animation it gives the same error in the Fighter.cs script. So, you should be able to set an empty void FootR and void FootL in the script using that animator to get rid of the issue.

1 Like

That sounds like it might work, do you know which script I would look in? I don’t have a lot of experience with the animations yet. Thanks

I don’t know where it’s supposed to go, but any script that uses GetComponent<Animator> to get those animations should work.

Thank you, that ended up being easier than I thought. For anyone else looking for solution to stop this, I just put the following lines of code at the end of my Mover.cs script and no more errors for this issue:

private void FootR() { }
private void FootL() { }

Thank you so much for the idea JamesD

EDIT: As JamesD mentioned, this problem came up in Video #33 (with ‘Hit’) of the new content because they are using animations from the same creator in the asset store. Basically they are events spawned by the animation that are there to help you do other things when they happen. I am guessing in the feet case, you could spawn footprints under each foot or some other effect. The solution there was simply to put the event (public and private both work) in whatever class seems logical that is a MonoBehavior type class attached to the object that is using the animation (for me, the ‘Player’ object’s Mover script)

I have a very important question. im trying to import my own characters into the rpg course and i wanted to know is, did the assets we important from polygon make the animation in blender or unity?

You would probably need to ask the folks who created the animation to find that out but perhaps @Marc_Carlyon or @Michael_Bridges would know if you canadd the event calls through Blender’s Animation package.

Its more likely that they were made but the asset creator in Maya not blender as such.
The event calls though however can be added to the existing animations or removed but you need to select the animation itself and pick the point in the time line to use it.
I believe we cover this in the attack sections as i brought this up with Sam and Rick in that why were we not using these in the old course as its there why not use it.

Hope this helps :slight_smile:

Animation isn’t working, can you help me with it.

Hi Rick,

My character transform is scaled to 3,3,3.
When character is moved by Animator Motion (with root motion checked), it’s ok.
When character is moved by navmeshagent (with root motion off), he moves like is scaled to 1,1,1 and not like 3,3,3 (you can try with character lesson to seeing effect).

How can risolve this problem?
Thanks,
Frank

ps. I’m italian, sorry for my english

Play around with the animation speed.

Thanks, I solved !!!
I’ve changed speed animation (bleeding) and now it’s ok.

1 Like

I am working through the course and got stuck on the walking animation part.
My character is not showing the moving animation.


Course 17
I am using Visual Studio.

On UpdateAnimation I am getting a Green line telling me
"Private member ‘Mover.UpdateAnimator’ is unused.’
private void UpdateAnimator()
{
Vector3 velocity = GetComponent().velocity;
Vector3 localVelocity = transform.InverseTransformDirection(velocity);
float speed = localVelocity.z;
GetComponent().SetFloat(“forwardSpeed” , speed);
}

I have done…
Reset Unity and Visual Studio
Checked all my {
checked Parameter name was the same

Please help me solve my animation proble

m.

Privacy & Terms