Adds Player controller
This commit is contained in:
commit
ab3890896d
35 changed files with 26403 additions and 0 deletions
24
scripts/player/cameraController.gd
Normal file
24
scripts/player/cameraController.gd
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
extends Camera3D
|
||||
|
||||
@export var PlayerNode: Node3D;
|
||||
|
||||
@export var turnSpeed: float = 0.25;
|
||||
@export var XRotationClamp: Vector2 = Vector2(-90, 90)
|
||||
|
||||
var currentRotation: Vector2 = Vector2(0,0);
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED;
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is not InputEventMouseMotion:
|
||||
return
|
||||
|
||||
var inputRotation = event.relative
|
||||
|
||||
self.currentRotation += Vector2(inputRotation.y, inputRotation.x) * self.turnSpeed * -1;
|
||||
|
||||
self.currentRotation.x = clamp(currentRotation.x, XRotationClamp.x, XRotationClamp.y);
|
||||
|
||||
self.rotation_degrees.x = currentRotation.x;
|
||||
self.PlayerNode.rotation_degrees.y = currentRotation.y
|
||||
Loading…
Add table
Add a link
Reference in a new issue