백지부터 시작하는 이세계 코딩 생활
unity 3D movement 구현하기 본문
Horizontal , Vertical 좌표값을 조작하여 Object ( Player ) 를 움직이기.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_HWPController : MonoBehaviour
{
private Rigidbody rigid;
private float moveForce = 7.0f;
private float x_Axis;
private float z_Axis;
// Start is called before the first frame update
void Start()
{
rigid = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
x_Axis = Input.GetAxis("Horizontal");
z_Axis = Input.GetAxis("Vertical");
Vector3 velocity = new Vector3(x_Axis, 0, z_Axis);
velocity *= moveForce;
rigid.velocity = velocity;
}
}
Ref. https://inyongs.tistory.com/17
'백지부터 시작하는 이세계 유니티 생활 since 2020' 카테고리의 다른 글
Coroutine, IEnumerator, yield return (0) | 2020.11.17 |
---|---|
parameter, argument (0) | 2020.11.17 |
override, overload (0) | 2020.11.17 |
Time.deltatime (0) | 2020.11.17 |
Update(), Input.GetKey() (0) | 2020.11.16 |
Comments