animator / animation not transitioning

first off why does this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TransitionAnim : MonoBehaviour
{
private Animator anim;
// Start is called before the first frame update
void Start()
{
anim = GetComponent();
}

// Update is called once per frame
void Update()
{
if(Input.GetAxis(Horizontal) || Input.GetAxis(Vertical))
{
anim.SetBool(“isRunning”, true);
}
else
{
anim.SetBool(“isRunning”, false);
}
}
}

show me this
Assets\TransitionAnim.cs(17,55): error CS0103: The name ‘Vertical’ does not exist in the current context

it never showed this until I went in and tried to add some stuff, but then ended up going back to exactly how it was saved initially, which is what is above. Its been happening a fair amount in other random scripts. It works then i go in and tinker, it doesn’t work and i put it back the way it was, and all of a sudden things are just unknown to unity for some ungodly reason.

My other problem is when i am attempting to create a transition, my character in the preview is somehow disconnected from whatever is happening in the preview window. It shows some sort of XYZ axis thing moving around. So nothing ever transitions. i’m new and super confused. appreciate any help. Also this script never actually performed a transition when it didn’t get any errors. IDK. again, I’m new and its super discouraging.

You need quotes around “Horizontal” and “Vertical”. Also, after you do that, it’ll tell you that it can’t convert a float to a bool, so you’ll need to do something like if (thing != 0f || thing != 0f) in your if statement. Also, when you post code, use code tags.

1 Like

it works. he transitions!
Still cant see preview in animator window when editing the transition
but this is a big step.
Thank you so much!
How do I give you some sort of karma!?! lol

You can Like my comment I guess? shrug

you should be able to drag your object from the editor hierarchy into the preview window - but doesn’t always work

once you get your head around “fixed duration” and “transition duration” it makes much more sense - basically you want the total of them to be 1.
i.e. if your fixed duration is 0.9 you want transition duration to be 0.1 or it will duplicate some of the end of the first animation again - this means it will always play 90% of the first animation then use the remaining 10% to swap to the new animation.
(these values are only used when when transitioning the animation - looping animations will play 100% until told otherwise).

Just go into the animation controller window, and click on the character it is effecting, and you should see the animation working in the graph. :wink: