Now About Social Code
summaryrefslogtreecommitdiff
path: root/addons/fpc/EditorModule.gd
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-17 22:02:33 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-17 22:02:33 +0100
commit0abec8156bd944aa883d544850ee1187219ba943 (patch)
tree55e222da361d176b0ba79611704b56e2d942a831 /addons/fpc/EditorModule.gd
Initial commit
Diffstat (limited to 'addons/fpc/EditorModule.gd')
-rw-r--r--addons/fpc/EditorModule.gd49
1 files changed, 49 insertions, 0 deletions
diff --git a/addons/fpc/EditorModule.gd b/addons/fpc/EditorModule.gd
new file mode 100644
index 0000000..fa1320b
--- /dev/null
+++ b/addons/fpc/EditorModule.gd
@@ -0,0 +1,49 @@
+@tool
+extends Node
+
+# This does not effect runtime yet but will in the future.
+
+@export_category("Controller Editor Module")
+@export_range(-360.0, 360.0, 0.01, "or_greater", "or_less") var head_y_rotation : float = 0.0:
+ set(new_rotation):
+ if HEAD:
+ head_y_rotation = new_rotation
+ HEAD.rotation.y = deg_to_rad(head_y_rotation)
+ update_configuration_warnings()
+@export_range(-90.0, 90.0, 0.01, "or_greater", "or_less") var head_x_rotation : float = 0.0:
+ set(new_rotation):
+ if HEAD:
+ head_x_rotation = new_rotation
+ HEAD.rotation.x = deg_to_rad(head_x_rotation)
+ update_configuration_warnings()
+
+@export_group("Nodes")
+@export var CHARACTER : CharacterBody3D
+@export var head_path : String = "Head" # Relative to the parent node
+#@export var CAMERA : Camera3D
+#@export var HEADBOB_ANIMATION : AnimationPlayer
+#@export var JUMP_ANIMATION : AnimationPlayer
+#@export var CROUCH_ANIMATION : AnimationPlayer
+#@export var COLLISION_MESH : CollisionShape3D
+
+@onready var HEAD = get_node("../" + head_path)
+
+
+func _ready():
+ if !Engine.is_editor_hint():
+ print("not editor")
+ HEAD.rotation.y = deg_to_rad(head_y_rotation)
+ HEAD.rotation.x = deg_to_rad(head_x_rotation)
+
+
+func _get_configuration_warnings():
+ var warnings = []
+
+ if head_y_rotation > 360:
+ warnings.append("The head rotation is greater than 360")
+
+ if head_y_rotation < -360:
+ warnings.append("The head rotation is less than -360")
+
+ # Returning an empty array gives no warnings
+ return warnings