1.挂载角色身上
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_Game : MonoBehaviour
{
private CharacterController controller;
public float Speed_Move = 5;
private void Start()
{
controller = GetComponent<CharacterController>();
}
void Update()
{
Move();
}
void Move()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 pos = this.transform.forward * v + this.transform.right * h;
controller.Move(pos * Speed_Move * Time.deltaTime);
}
}
2.挂载摄像机身上 ,摄像机作为角色子集
using System.Collections;
using System.Collections.Generic;
u