using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour
{
public float speed = 5;
private void Update()
{
float v = Input.GetAxis("Vertical");
float h = Input.GetAxis("Horizontal");
if (v != 0 || h != 0)
Movement(v, h);
}
private void Movement(float v, float h)
{
this.transform.Translate(0, 0, speed*Time .deltaTime );
Quaternion dir = Quaternion.LookRotation(new Vector3(h, 0, v));
this.transform.rotation =
Quaternion.Lerp(this.transform.rotation, dir, 0.1f);
}
//正交相机
private void LookMousepoint()
{
Vector3 mp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.LookAt(new Vector3(mp.x, transform.position.y, mp.z));
}
//通用相机
private void LookMousepointPr()
{
RaycastHit hit;
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),out hit))
transform.LookAt(new Vector3(hit.point.x, transform.position.y, hit.point.z));
}
}