initial commit
This commit is contained in:
44
Assets/Scripts/Player Controls/player_movement.gd
Normal file
44
Assets/Scripts/Player Controls/player_movement.gd
Normal file
@@ -0,0 +1,44 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var camera: Camera3D = $Camera3D
|
||||
@export var verticalLookLimit: float = deg_to_rad(50)
|
||||
|
||||
|
||||
@export var psxScene: PackedScene
|
||||
var psxInstance: Node = null
|
||||
var togglePsxEffect: bool = false
|
||||
#@export var horizontalLookRightLimit: float = deg_to_rad(290)
|
||||
#@export var horizontalLookLeftLimit: float = deg_to_rad(-196)
|
||||
var cameraPitch: float = 0.0
|
||||
var cameraYaw: float = 0.0
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
var currentRot = camera.rotation
|
||||
cameraPitch = currentRot.x
|
||||
cameraYaw = currentRot.y
|
||||
camera.rotation.z = 0.0
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
cameraPitch -= event.screen_relative.y * GlobalSettings.cameraSensitivity
|
||||
cameraYaw -= event.screen_relative.x * GlobalSettings.cameraSensitivity
|
||||
#cameraPitch = clamp(cameraPitch, -verticalLookLimit, verticalLookLimit)
|
||||
#cameraYaw = clamp(cameraYaw, -horizontalLookLeftLimit, horizontalLookRightLimit)
|
||||
cameraPitch = clamp(cameraPitch, -verticalLookLimit, verticalLookLimit)
|
||||
camera.rotation = Vector3(cameraPitch, cameraYaw, 0)
|
||||
|
||||
if Input.is_action_just_released("PSX Theme toggle"):
|
||||
togglePsxEffect = !togglePsxEffect
|
||||
|
||||
if togglePsxEffect:
|
||||
psxInstance = psxScene.instantiate()
|
||||
add_child(psxInstance)
|
||||
else:
|
||||
psxInstance.queue_free()
|
||||
psxInstance = null
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user