using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
private float lengthwaysSpeed = 5; //纵向
private float crosswiseSpeed = 45; //横向
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.W))
{
transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * lengthwaysSpeed);
}
if (Input.GetKey(KeyCode.S))
{
transform.Translate(-Vector3.back * Time.deltaTime * Input.GetAxis("Vertical") * lengthwaysSpeed);
}
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.up * Time.deltaTime * Input.GetAxis("Horizontal") * crosswiseSpeed);
}
if (Input.GetKey(KeyCode.D))
{
transform.Rotate(-Vector3.down * Time.deltaTime * Input.GetAxis("Horizontal") * crosswiseSpeed);
}
}
}
1819






