using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float speed;
float hAxis;
float vAxis;
bool wDown;
Vector3 = moveVec;
Animator anim;
void Start()
{
anim = GetComponentInChildren<Animator>();
}
void Update()
{
hAxis = Input.GetAxisRaw("Horizontal");
vAxis = Input.GetAxisRaw("Vertical");
wDown = Input.GetButton("Walk");
moveVec = new Vector3(hAxis, 0, vAxis).normalized;
transform.position += moveVec * speed * Time.deltaTime;
anim.SetBool("isRun", moveVec != Vector3.zero);
anim.SetBool("isWalk", wDown);
}
}
에서 anim.SetBool("isRun", moveVec != Vector3.zero); 이쪽줄에 null 오류가 나네요 ㅠㅠ 어디서 잘못된건가요?
anim = GetComponentInChildren(); 을 anim = GetComponent(); 로 바꿔보셈
'Animator' is a type, which is not valid in the given context 라고 뜨네요 ㅠㅠ
저거 꺽쇠도 같이 해야지 이거 디시 오류때문에 < 이 꺽쇠 괄호 없어짐 >
스크립트 달린 오브젝트나 그보다 하위 계층에 애니메이터 컴포넌트가 있어야 함
덕분에 해결했습니다 감사합니다