unity做单机游戏,用Rigidbody控制角色移动与朝向问题(毕设过程中的一些心得)
Vector3 nowVel = rig.velocity;
rig.velocity = new Vector3 (velocity * h, nowVel.y, velocity * v); //移动
transform.LookAt (new Vector3 (h, 0, v) + transform.position); //朝向
`这是个人做的项目中的移动代码,最好看看有选择性的复制,并不是所有的东西都是你需要的,只是做一个例子,多余的就不解释了。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour {
public float velocity = 5; //速度
private Rigidbody rig;
privat