解决unity中角色斜向走路/跑变快的问题

注意:v为vertical h为horizontal
//将以前坐标x,z进行公式计算 output出新的坐标
Vector3 output = Vector3.zero;
output.x = h* Mathf.Sqrt(1 - (v * v) / 2.0f);
output.z = v * Mathf.Sqrt(1 - (h * h) / 2.0f);
this.playerRigdbody.velocity = new Vector3(output.x, this.playerRigdbody.velocity.y, output.z) * this.runSpeed * Time.deltaTime;

你可能感兴趣的:(随笔)