Hey guys^^
I wanted to write a script that changes the AnimatorController of my player during the runtime. If I press 1 it should be the first controller by press 2 it should be the second.
Okay this is what I have so far:
using UnityEngine;
using System.Collections;
public class SwitchAnimator : MonoBehaviour {
Animator animator;
void Start () {
animator = this.GetComponent<Animator>();
}
void Update () {
if (Input.GetKeyDown ("1")) {
animator.runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Animation/Char1Animator.controller", typeof(RuntimeAnimatorController )));
}
if (Input.GetKeyDown ("2")) {
animator.runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Animation/C1AnimatorRange.controller", typeof(RuntimeAnimatorController )));
}
}
}
But I get an “ArgumentException: The thing you want to instantiate is null” error. What did I wrote wrong?
Thank you so much^^