Rigidbody 오류
448
작성한 질문수 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField]
private float walkSpeed;
[SerializeField]
private Rigidbody myRigid;
// Start is called before the first frame update
void Start()
{
myRigid = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
Move();
}
private void Move()
{
float _moveDirX = Input.GetAxisRaw("Horizontal");
float _moveDirZ = Input.GetAxisRaw("Vertical");
Vector3 _moveHorizontal = transform.right * _moveDirX;
Vector3 _moveVertical = transform.forward * _moveDirZ;
Vector3 _velocity = (_moveHorizontal + _moveVertical).normalized * walkSpeed;
myRigid.MovePosition(transform.position + _velocity * Time.deltaTime);
}
}
이렇게 작성했는데 MissingComponentException: There is no 'Rigidbody' attached to the "Player" game object, but a script is trying to access it. 오류가 나요 뭐가문제죠?
답변 0
ResourceManager 클래스 관련 질문
1
20
2
FBX chan 모델
0
14
1
첨부된 수업자료와 강의 내용이 다릅니다.
0
34
2
몬스터 HP 게이지바 이동
0
20
1
TextMeshPro용 커스텀 한글 2350자.txt 파일은 어디에 있나요?
0
22
1
02-02 NavMesh 응용 캐릭터 멈춤 문제
0
33
1
02-02 NavMesh 응용 캐릭터 멈춤 문제
0
41
2
C#에서의 RAII
0
62
3
Scene 뷰에서 Enemy Entity가 보이지 않는 문제
0
46
2
Lessons 3 & 4 don't have subtitles unfortunately
0
39
1
클로드코드 + 유니티 컨텐츠만들기 응용에 대하여 질문드립니다.
0
66
1
매니저 관련 질문이 있습니다.
0
69
2
Instantiate
0
48
2
유니티 허브 다운로드
1
62
2
비쥬얼 스튜디오에서 unity연결이 없습니다.
0
74
2
UserDataManager 클래스 hasSaveError 처리
0
46
2
트랜지션 추가가 불가능하여 여쭤봅니다
0
314
0
처음 playerscript 어디가 틀렸나요?
1
335
1
Asset 파일링크
0
339
1
너무 작동이 안됩니다
0
217
0
에셋 안넣어져요
0
375
3
기본무기를 맨손으로 하고싶어요!
0
311
0
특정 아이템이 인벤토리에 존재하면 특정 행동을 할 수 있게 적용 하는 방법이 있나요?
0
235
0
중간에 앉기 기능이 있는데 컨트롤키를 누르고 있을때만 앉아 있을수 없나요?
0
309
1





