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.
42 lines
924 B
42 lines
924 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraMove : MonoBehaviour
|
|
{
|
|
public CharacterController CharacterController;
|
|
|
|
[Header("Move")]
|
|
public float Speed = 12f;
|
|
public float Gravity = 20f;
|
|
private Vector3 m_Velocity;
|
|
|
|
|
|
|
|
private void Start()
|
|
{
|
|
try { CharacterController = GetComponent<CharacterController>(); }
|
|
catch { CharacterController = null; }
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
}
|
|
void Update()
|
|
{
|
|
|
|
|
|
//Æ½ÃæÒÆ¶¯
|
|
float x = Input.GetAxis("Horizontal");
|
|
float y = Input.GetAxis("Vertical");
|
|
|
|
Vector3 MoveDir = transform.right * x + transform.forward * y;
|
|
|
|
CharacterController.Move(MoveDir * Speed * Time.deltaTime);
|
|
|
|
//×ÔÓÉÂäÌå
|
|
m_Velocity.y -= Time.deltaTime * Gravity;
|
|
|
|
CharacterController.Move(m_Velocity * Time.deltaTime);
|
|
|
|
|
|
}
|
|
}
|