###解決したいこと
animcontroller.csのAnimator型の変数aimはインスペクター上ではちゃんと割り当てられているのに下のようなエラーが出ます
ちなみにアニメーターは
###animcontroller.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class animcon : MonoBehaviour
{
public Animator anim;
public float speed=0;
// Start is called before the first frame update
void Start()
{
} // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.W)) { speed += 0.5f*Time.deltaTime; anim.SetFloat("speed", speed); } else{ anim.SetFloat("speed", 0); } }
}
###エラーメッセージ
UnassignedReferenceException: The variable anim of animcontroller has not been assigned.
You probably need to assign the anim variable of the animcontroller script in the inspector.
UnityEngine.Animator.SetFloat (System.String name, System.Single value) (at C:/buildslave/unity/build/Modules/Animation/ScriptBindings/Animator.bindings.cs:329)
animcontroller.Update () (at Assets/Easy FPS/Model_Animations_Textures/main character/script/animcontroller.cs:24)
回答1件
あなたの回答
tips
プレビュー