Improve editor module

This commit is contained in:
2024-07-23 19:07:42 -07:00
parent 6c719b52cc
commit 3567b157c0
2 changed files with 21 additions and 21 deletions

View File

@ -1,39 +1,40 @@
@tool
extends Node
# This module affects runtime nad
# This does not effect runtime yet but will in the future.
#TODO: Add descriptions
@export_category("Controller Editor Module")
@export var head_y_rotation : float = 0:
@export_range(-360.0, 360.0, 0.01, "or_greater", "or_less") var head_y_rotation : float = 0.0:
set(new_rotation):
head_y_rotation = new_rotation
HEAD.rotation.y = head_y_rotation
update_configuration_warnings()
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" # From this nodes parent node
@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
var HEAD
@onready var HEAD = get_node("../" + head_path)
func _ready():
HEAD = get_node("../" + head_path)
if Engine.is_editor_hint():
pass
else:
HEAD.rotation.y = head_y_rotation
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 _process(delta):
if Engine.is_editor_hint():
pass
func _get_configuration_warnings():
var warnings = []
@ -41,8 +42,8 @@ func _get_configuration_warnings():
if head_y_rotation > 360:
warnings.append("The head rotation is greater than 360")
if head_y_rotation < 0:
warnings.append("The head rotation is less than 0")
if head_y_rotation < -360:
warnings.append("The head rotation is less than -360")
# Returning an empty array gives no warnings
return warnings