mirror of
https://github.com/celisej567/UnitySourceMovement.git
synced 2026-01-04 06:09:40 +03:00
More consistent variable naming convention
This commit is contained in:
@@ -15,7 +15,7 @@ public class PlayerAiming : MonoBehaviour
|
|||||||
public float maxYRotation = 90f;
|
public float maxYRotation = 90f;
|
||||||
|
|
||||||
//The real rotation of the camera without recoil
|
//The real rotation of the camera without recoil
|
||||||
private Vector3 real_rotation;
|
private Vector3 realRotation;
|
||||||
|
|
||||||
[Header("Aimpunch")]
|
[Header("Aimpunch")]
|
||||||
[Tooltip("bigger number makes the response more damped, smaller is less damped, currently the system will overshoot, with larger damping values it won't")]
|
[Tooltip("bigger number makes the response more damped, smaller is less damped, currently the system will overshoot, with larger damping values it won't")]
|
||||||
@@ -46,31 +46,31 @@ public class PlayerAiming : MonoBehaviour
|
|||||||
DecayPunchAngle();
|
DecayPunchAngle();
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
float x_movement = Input.GetAxisRaw("Mouse X") * horizontalSensitivity * sensitivityMultiplier;
|
float xMovement = Input.GetAxisRaw("Mouse X") * horizontalSensitivity * sensitivityMultiplier;
|
||||||
float y_movement = -Input.GetAxisRaw("Mouse Y") * verticalSensitivity * sensitivityMultiplier;
|
float yMovement = -Input.GetAxisRaw("Mouse Y") * verticalSensitivity * sensitivityMultiplier;
|
||||||
|
|
||||||
// Calculate real rotation from input
|
// Calculate real rotation from input
|
||||||
real_rotation = new Vector3(Mathf.Clamp(real_rotation.x + y_movement, minYRotation, maxYRotation), real_rotation.y + x_movement, real_rotation.z);
|
realRotation = new Vector3(Mathf.Clamp(realRotation.x + yMovement, minYRotation, maxYRotation), realRotation.y + xMovement, realRotation.z);
|
||||||
real_rotation.z = Mathf.Lerp(real_rotation.z, 0f, Time.deltaTime * 3f);
|
realRotation.z = Mathf.Lerp(realRotation.z, 0f, Time.deltaTime * 3f);
|
||||||
|
|
||||||
//Apply real rotation to body
|
//Apply real rotation to body
|
||||||
bodyTransform.eulerAngles = Vector3.Scale(real_rotation, new Vector3(0f, 1f, 0f));
|
bodyTransform.eulerAngles = Vector3.Scale(realRotation, new Vector3(0f, 1f, 0f));
|
||||||
|
|
||||||
//Apply rotation and recoil
|
//Apply rotation and recoil
|
||||||
Vector3 camera_euler_punch_applied = real_rotation;
|
Vector3 cameraEulerPunchApplied = realRotation;
|
||||||
camera_euler_punch_applied.x += punchAngle.x;
|
cameraEulerPunchApplied.x += punchAngle.x;
|
||||||
camera_euler_punch_applied.y += punchAngle.y;
|
cameraEulerPunchApplied.y += punchAngle.y;
|
||||||
|
|
||||||
transform.eulerAngles = camera_euler_punch_applied;
|
transform.eulerAngles = cameraEulerPunchApplied;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ViewPunch(Vector2 punch_amount)
|
public void ViewPunch(Vector2 punchAmount)
|
||||||
{
|
{
|
||||||
//Remove previous recoil
|
//Remove previous recoil
|
||||||
punchAngle = Vector2.zero;
|
punchAngle = Vector2.zero;
|
||||||
|
|
||||||
//Recoil go up
|
//Recoil go up
|
||||||
punchAngleVel -= punch_amount * 20;
|
punchAngleVel -= punchAmount * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DecayPunchAngle()
|
private void DecayPunchAngle()
|
||||||
@@ -85,8 +85,8 @@ public class PlayerAiming : MonoBehaviour
|
|||||||
|
|
||||||
punchAngleVel *= damping;
|
punchAngleVel *= damping;
|
||||||
|
|
||||||
float spring_force_magnitude = punchSpringConstant * Time.deltaTime;
|
float springForceMagnitude = punchSpringConstant * Time.deltaTime;
|
||||||
punchAngleVel -= punchAngle * spring_force_magnitude;
|
punchAngleVel -= punchAngle * springForceMagnitude;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -94,4 +94,4 @@ public class PlayerAiming : MonoBehaviour
|
|||||||
punchAngleVel = Vector2.zero;
|
punchAngleVel = Vector2.zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user