- Home /
trouble with run animations
im using unity 2018.3.6 Iv created an avatar using UMA and written a script from a YouTube tutorial to make character click to walk.I must be missing something here.
Here are images of animator, error and also script. any help much appreciated!!!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class ClickToMove : MonoBehaviour
{
private Animator mAnimator;
private NavMeshAgent mNavMeshAgent;
private bool mRunning = false;
// Start is called before the first frame update
void Start()
{
mAnimator = GetComponent<Animator>();
mNavMeshAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray, out hit, 100))
{
mNavMeshAgent.destination = hit.point;
}
}
if (mNavMeshAgent.remainingDistance < mNavMeshAgent.stoppingDistance)
{
mRunning = false;
}
else;
{
mRunning = true;
}
mAnimator.SetBool("running", mRunning);
}
}
@msmoyle did you attached the correct animator controller which is having parameter(running) to the object?
Answer by BusyRoots · Mar 08, 2019 at 10:07 AM
I assume the script "ClickToMove" is attached to the same gameobject where the animator component with the "running" parameter is attached to, right?
If that is the case, make sure your script and scene is saved (in case you made currently changes to your variable names). If this doesn't help too, try out writing "running" with an capitalized "R" in your script like the warning says.