In-editor tools module
This commit is contained in:
48
addons/fpc/EditorModule.gd
Normal file
48
addons/fpc/EditorModule.gd
Normal file
@ -0,0 +1,48 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
# This module affects runtime nad
|
||||
|
||||
|
||||
#TODO: Add descriptions
|
||||
@export_category("Controller Editor Module")
|
||||
@export var head_y_rotation : float = 0:
|
||||
set(new_rotation):
|
||||
head_y_rotation = new_rotation
|
||||
HEAD.rotation.y = head_y_rotation
|
||||
update_configuration_warnings()
|
||||
|
||||
@export_group("Nodes")
|
||||
@export var CHARACTER : CharacterBody3D
|
||||
@export var head_path : String = "Head" # From this nodes 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
|
||||
|
||||
|
||||
func _ready():
|
||||
HEAD = get_node("../" + head_path)
|
||||
if Engine.is_editor_hint():
|
||||
pass
|
||||
else:
|
||||
HEAD.rotation.y = head_y_rotation
|
||||
|
||||
func _process(delta):
|
||||
if Engine.is_editor_hint():
|
||||
pass
|
||||
|
||||
func _get_configuration_warnings():
|
||||
var 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")
|
||||
|
||||
# Returning an empty array gives no warnings
|
||||
return warnings
|
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://cc1m2a1obsyn4"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://cc1m2a1obsyn4"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/fpc/character.gd" id="1_0t4e8"]
|
||||
[ext_resource type="Script" path="res://addons/fpc/EditorModule.gd" id="3_v3ckk"]
|
||||
[ext_resource type="Script" path="res://addons/fpc/debug.gd" id="3_x1wcc"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_kp17n"]
|
||||
@ -455,3 +456,6 @@ layout_mode = 2
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("SphereShape3D_k4wwl")
|
||||
target_position = Vector3(0, 0.5, 0)
|
||||
|
||||
[node name="EditorModule" type="Node" parent="."]
|
||||
script = ExtResource("3_v3ckk")
|
||||
|
Reference in New Issue
Block a user