- Home /
run animation when should idle
Problem, character is click to walk via script written from tutorial on YouTube. when i hit play mode both animations begin to cycle in the animator but the run animaton wins out and cycles while character isnt moving.
Im using unity 2018.3.6 and UMA for character i have a parameter called Running which is set to true for transition to run animation and false for transition back to idle
script here
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);
}
}
Answer by Nivbot · Mar 09, 2019 at 06:42 AM
You have a ; after else. I would think that would throw an error but if not it shouldn’t be there. I can’t really see anything else.
you have set my spirit free Nivbot. I can finally move on to a better place.
Your answer
Follow this Question
Related Questions
Why when creating new animator controller for the character the character is not walking right ? 0 Answers
How can i check if animation has finished playing if the object have no animator attached ? 1 Answer
Animator Trigger Not Working 1 Answer
How to have a collider inactive only during attack animation and not during 'charging' animation? 1 Answer
Need Help Syncing door animations between all clients! 0 Answers