강의

멘토링

커뮤니티

Inflearn Community Q&A

jirotv15781882's profile image
jirotv15781882

asked

[Unity 3D] FPS Survival Defense

Basic character movements

처음 playerscript 어디가 틀렸나요?

Written on

·

319

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);
    }

}
unity

Answer 1

0

Jiro TV님의 프로필 이미지
Jiro TV
Questioner

transform의 철자는 고쳤습니다

jirotv15781882's profile image
jirotv15781882

asked

Ask a question