gd: fixed look inputs
This commit is contained in:
@ -8,7 +8,7 @@ namespace PolarBears.PlayerControllerAddon;
|
||||
public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
// User API to important child nodes.
|
||||
public Node3D Head;
|
||||
public HeadSystem HeadSystem;
|
||||
public Bobbing Bobbing;
|
||||
public FieldOfView FieldOfView;
|
||||
public Stamina Stamina;
|
||||
@ -18,7 +18,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
public CapsuleCollider CapsuleCollider;
|
||||
public Gravity Gravity;
|
||||
public HealthSystem HealthSystem;
|
||||
public Mouse Mouse;
|
||||
|
||||
|
||||
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
||||
public float WalkSpeed { get; set; } = 5.0f;
|
||||
@ -31,9 +31,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
|
||||
public float DoubleJumpSpeedFactor { get; set; } = 2f;
|
||||
|
||||
[Export(PropertyHint.Range, "1,50,1,or_greater")]
|
||||
public float ControllerSensitivity { get; set; } = 20f;
|
||||
|
||||
private bool _canDoubleJump = true;
|
||||
private bool _movementEnabled = true;
|
||||
@ -100,7 +97,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
_currentSpeed = WalkSpeed;
|
||||
|
||||
Head = GetNode<Node3D>("Head");
|
||||
HeadSystem = GetNode<HeadSystem>("HeadSystem");
|
||||
HeadSystem.Init();
|
||||
|
||||
_headCollisionDetectors = new RayCast3D[NumOfHeadCollisionDetectors];
|
||||
|
||||
@ -111,25 +109,23 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
|
||||
// Getting dependencies of the components(In godot we manage this from upwards to downwards not vice versa)
|
||||
Camera3D camera = GetNode<Camera3D>("Head/CameraSmooth/Camera3D");
|
||||
Camera3D camera = GetNode<Camera3D>("HeadSystem/CameraSmooth/Camera3D");
|
||||
|
||||
RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D");
|
||||
RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D");
|
||||
|
||||
Node3D cameraSmooth = GetNode<Node3D>("Head/CameraSmooth");
|
||||
|
||||
AnimationPlayer animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
Node3D cameraSmooth = GetNode<Node3D>("HeadSystem/CameraSmooth");
|
||||
|
||||
// Getting universal setting from GODOT editor to be in sync
|
||||
float gravitySetting = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
|
||||
|
||||
ColorRect vignetteRect = GetNode<ColorRect>(
|
||||
"Head/CameraSmooth/Camera3D/CLVignette(Layer_1)/HealthVignetteRect");
|
||||
"HeadSystem/CameraSmooth/Camera3D/CLVignette(Layer_1)/HealthVignetteRect");
|
||||
|
||||
ColorRect distortionRect = GetNode<ColorRect>(
|
||||
"Head/CameraSmooth/Camera3D/CLDistortion(Layer_2)/HealthDistortionRect");
|
||||
"HeadSystem/CameraSmooth/Camera3D/CLDistortion(Layer_2)/HealthDistortionRect");
|
||||
|
||||
ColorRect blurRect = GetNode<ColorRect>("Head/CameraSmooth/Camera3D/CLBlur(Layer_2)/BlurRect");
|
||||
ColorRect blurRect = GetNode<ColorRect>("HeadSystem/CameraSmooth/Camera3D/CLBlur(Layer_2)/BlurRect");
|
||||
|
||||
Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
|
||||
|
||||
@ -148,10 +144,10 @@ public partial class PlayerController : CharacterBody3D
|
||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||
|
||||
MantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
MantleSystem.Init(Head);
|
||||
MantleSystem.Init(HeadSystem);
|
||||
|
||||
DashSystem = GetNode<DashSystem>("DashSystem");
|
||||
DashSystem.Init(Head, camera);
|
||||
DashSystem.Init(HeadSystem, camera);
|
||||
|
||||
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");
|
||||
|
||||
@ -165,17 +161,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
Gravity = Gravity,
|
||||
Parent = this,
|
||||
Camera = camera,
|
||||
AnimationPlayer = animationPlayer,
|
||||
Head = Head,
|
||||
Head = HeadSystem,
|
||||
VignetteRect = vignetteRect,
|
||||
DistortionRect = distortionRect,
|
||||
BlurRect = blurRect,
|
||||
};
|
||||
|
||||
HealthSystem.Init(healthSystemParams);
|
||||
|
||||
Mouse = GetNode<Mouse>("Mouse");
|
||||
Mouse.Init(Head, camera, HealthSystem.IsDead);
|
||||
}
|
||||
|
||||
private void DisableMovement()
|
||||
@ -325,16 +317,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
_currentSpeed = SprintSpeed;
|
||||
}
|
||||
|
||||
// Vector2 inputLookDir = Input.GetVector("look_left", "look_right", "look_up", "look_down");
|
||||
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
|
||||
Mouse.LookAround(-1 * ControllerSensitivity * inputLookDir);
|
||||
HeadSystem.LookAround(inputLookDir);
|
||||
|
||||
// Basis is a 3x4 matrix. It contains information about scaling and rotation of head.
|
||||
// By multiplying our Vector3 by this matrix we're doing multiple things:
|
||||
// a) We start to operate in global space;
|
||||
// b) We're applying to Vector3 the current rotation of "head" object;
|
||||
// c) We're applying to Vector3 the current scaling of "head" object;
|
||||
Vector3 direction = Head.Transform.Basis * _inputMove;
|
||||
Vector3 direction = HeadSystem.Transform.Basis * _inputMove;
|
||||
|
||||
if (isPlayerDead)
|
||||
{
|
||||
|
Reference in New Issue
Block a user