Move camera rotation to Player from LocalPlayer
This commit is contained in:
parent
3ee35707e2
commit
10fe5bfd3a
@ -15,7 +15,7 @@ namespace NeonTea.Quakeball.Animation {
|
|||||||
private Vector2 TargetLean = Vector2.zero;
|
private Vector2 TargetLean = Vector2.zero;
|
||||||
|
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
transform.parent = Player.Camera;
|
transform.parent = Player.Player.CameraRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update() {
|
private void Update() {
|
||||||
|
@ -8,13 +8,10 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
/// <summary>A controller class for a local player. Handles input and updates the relevant components.</summary>
|
/// <summary>A controller class for a local player. Handles input and updates the relevant components.</summary>
|
||||||
[RequireComponent(typeof(Player))]
|
[RequireComponent(typeof(Player))]
|
||||||
public class LocalPlayer : MonoBehaviour {
|
public class LocalPlayer : MonoBehaviour {
|
||||||
public Transform Camera;
|
|
||||||
public bool DisableInput = false;
|
public bool DisableInput = false;
|
||||||
public float FullSyncFrequency = 1;
|
public float FullSyncFrequency = 1;
|
||||||
|
|
||||||
private float Lean = 0;
|
public Player Player { private set; get; }
|
||||||
|
|
||||||
private Player Player;
|
|
||||||
public InputAction LookAction { private set; get; }
|
public InputAction LookAction { private set; get; }
|
||||||
private InputAction MoveAction;
|
private InputAction MoveAction;
|
||||||
private InputAction CrouchAction;
|
private InputAction CrouchAction;
|
||||||
@ -89,9 +86,6 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
||||||
Player.Pitch = Mathf.Clamp(Player.Pitch - LookInput.y * (Opts.InvertVerticalLook ? -1 : 1), -90, 90);
|
Player.Pitch = Mathf.Clamp(Player.Pitch - LookInput.y * (Opts.InvertVerticalLook ? -1 : 1), -90, 90);
|
||||||
Player.Yaw += LookInput.x;
|
Player.Yaw += LookInput.x;
|
||||||
float TargetLean = -Vector3.Dot(Player.GroundVelocity / Player.MoveStyle.TargetVelocity, Camera.right) * Player.MoveStyle.LeanDegrees;
|
|
||||||
Lean = Mathf.Lerp(Lean, TargetLean, 30f * Time.deltaTime);
|
|
||||||
Camera.localEulerAngles = new Vector3(Player.Pitch, Player.Yaw, Lean);
|
|
||||||
|
|
||||||
if (Time.time - PreviousPlayerUpdate >= 1f / Player.UpdateFrequency) {
|
if (Time.time - PreviousPlayerUpdate >= 1f / Player.UpdateFrequency) {
|
||||||
PreviousPlayerUpdate = Time.time;
|
PreviousPlayerUpdate = Time.time;
|
||||||
|
@ -30,6 +30,7 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
|
|
||||||
[Header("Visuals")]
|
[Header("Visuals")]
|
||||||
public DesyncLerper[] Lerpables;
|
public DesyncLerper[] Lerpables;
|
||||||
|
public float Lean;
|
||||||
|
|
||||||
[Header("Player rotation status")]
|
[Header("Player rotation status")]
|
||||||
/// <summary>The pitch of the player's head.</summary>
|
/// <summary>The pitch of the player's head.</summary>
|
||||||
@ -177,6 +178,11 @@ namespace NeonTea.Quakeball.Players {
|
|||||||
}
|
}
|
||||||
Body.localRotation = Quaternion.Lerp(Body.localRotation, Quaternion.Euler(0, BodyYaw, 0), 20f * Time.deltaTime);
|
Body.localRotation = Quaternion.Lerp(Body.localRotation, Quaternion.Euler(0, BodyYaw, 0), 20f * Time.deltaTime);
|
||||||
Head.localRotation = Quaternion.Lerp(Head.localRotation, Quaternion.Euler(Pitch, Yaw, 0), 15f * Time.deltaTime);
|
Head.localRotation = Quaternion.Lerp(Head.localRotation, Quaternion.Euler(Pitch, Yaw, 0), 15f * Time.deltaTime);
|
||||||
|
|
||||||
|
float TargetLean = -Vector3.Dot(GroundVelocity / MoveStyle.TargetVelocity, CameraRoot.right) * MoveStyle.LeanDegrees;
|
||||||
|
Lean = Mathf.Lerp(Lean, TargetLean, 30f * Time.deltaTime);
|
||||||
|
CameraRoot.localEulerAngles = new Vector3(Pitch, Yaw, Lean);
|
||||||
|
|
||||||
UpdateMovement();
|
UpdateMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user