• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

처음 playerscript 어디가 틀렸나요?

21.04.07 14:49 작성 조회수 194

1

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour{

[SerializeField]
private float walkSpeed;



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 = transfrom.right * _moveDirX;
        Vector3 _moveVertical = transfrom.forward * _moveDirZ;

        Vector3 _velocity = (_moveHorizontal + _moveVertical).normalized * walkSpeed;

        myRigid.MovePosition(transfrom.position + _velocity * Time.deltaTime);
    }

}

답변 1

답변을 작성해보세요.

0

Jiro TV님의 프로필

Jiro TV

질문자

2021.04.07

transform의 철자는 고쳤습니다