- Home /
AnimatorOverrideController can't take 1 argument
Ok so, I am following this tutorial and my issue is that "overrideController = new AnimatorOverrideController(animator.runtimeAnimatorController);" has an error that states that AnimatorOverrideController "does not contain a constructor that takes 1 argument". From why I can tell EVERYTHING is just as it is in the tutorial and I can't find anything that helps on the internet. Help would be greatly appreachiated.
Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class playerAnimator : MonoBehaviour
{
public AnimationClip replacableAttackAnim;
public AnimationClip[] defaultAttackAnimSet;
protected AnimationClip[] currentAttackAnimSet;
const float locomotionAnimationSmoothTime = 0.1f;
NavMeshAgent agent;
protected Animator animator;
protected CharacterCombat combat;
protected AnimatorOverrideController overrideController;
protected virtual void Start()
{
agent = GetComponent<NavMeshAgent>();
animator = GetComponentInChildren<Animator>();
combat = GetComponent<CharacterCombat>();
overrideController = new AnimatorOverrideController(animator.runtimeAnimatorController);
animator.runtimeAnimatorController = overrideController;
currentAttackAnimSet = defaultAttackAnimSet;
combat.OnAttack += OnAttack;
}
protected virtual void Update()
{
float speedPercent = agent.velocity.magnitude / agent.speed;
animator.SetFloat("speedPercent", speedPercent, locomotionAnimationSmoothTime, Time.deltaTime);
animator.SetBool("inCombat", combat.InCombat);
}
protected virtual void OnAttack()
{
animator.SetTrigger("attack");
int attackIndex = Random.Range(0, currentAttackAnimSet.Length);
overrideController[replacableAttackAnim.name] = currentAttackAnimSet[attackIndex];
}
}
Answer by Jonny010 · Feb 13, 2019 at 01:37 PM
Hello there!
Actually I had the exact same problem while watching exactly the same video!
It seemed like my unity-framework was outdated for some odd reason, so I had to reinstall everything (including Visual Studio, because why not?). Just to be sure you should look for any remaining files that weren't deleted during uninstallation. Normally Unity is installed in the ProgramFiles-folder.
I don't know if there is a better way to fix this, but that worked for me.