浏览代码

Changed the new variable into a constant

/main
Ciro Continisio 4 年前
当前提交
69c48251
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 5
      UOP1_Project/Assets/Scripts/Characters/Character.cs

5
UOP1_Project/Assets/Scripts/Characters/Character.cs


private float verticalMovement = 0f; //Represents how much a player will move vertically in a frame. Affected by gravity * gravityContributionMultiplier
private Vector3 inputVector; //Initial input horizontal movement (y == 0f)
private Vector3 movementVector; //Final movement vector
private float rotationThreshold = .02f; // Used to prevent NaN result causing rotation in a non direction
private const float ROTATION_TRESHOLD = .02f; // Used to prevent NaN result causing rotation in a non direction
private void Awake()
{

//Rotate to the movement direction
movementVector.y = 0f;
if (movementVector.sqrMagnitude >= rotationThreshold)
if (movementVector.sqrMagnitude >= ROTATION_TRESHOLD)
{
float targetRotation = Mathf.Atan2(movementVector.x, movementVector.z) * Mathf.Rad2Deg;
transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(

正在加载...
取消
保存