You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
968 B
33 lines
968 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
public class PlayerMove : MonoBehaviour
|
|
{
|
|
CharacterController characterController;
|
|
[Header("Move")]
|
|
public float Speed = 2f;
|
|
public float Gravity = 20f;
|
|
Vector3 m_Velocity;
|
|
private void Awake()
|
|
{
|
|
characterController = GetComponent<CharacterController>();
|
|
}
|
|
private void Update()
|
|
{
|
|
if (!GameManager.GetInstance().IsPlayerMove)
|
|
{
|
|
characterController.Move(new Vector3(0, 0, 0));
|
|
return;
|
|
}
|
|
float _Horizontal = Input.GetAxis("Horizontal");
|
|
float _Vertical = Input.GetAxis("Vertical");
|
|
Vector3 Dir = transform.right * _Horizontal + transform.forward * _Vertical;
|
|
characterController.Move(Dir * Speed * Time.deltaTime);
|
|
|
|
m_Velocity.y -= Time.deltaTime * Gravity;
|
|
|
|
characterController.Move(m_Velocity * Time.deltaTime);
|
|
}
|
|
}
|