Many Many Updates
This commit is contained in:
parent
1608b8f6f5
commit
8359479243
50 changed files with 807 additions and 66 deletions
5
Scripts/GL_Animatable.gd
Normal file
5
Scripts/GL_Animatable.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends Node
|
||||
class_name GL_Animatable
|
||||
|
||||
func _sent_signals(signal_ID:String,the_signal):
|
||||
pass
|
1
Scripts/GL_Animatable.gd.uid
Normal file
1
Scripts/GL_Animatable.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://hetlgruo7m0b
|
22
Scripts/GL_Animatronic.gd
Normal file
22
Scripts/GL_Animatronic.gd
Normal file
|
@ -0,0 +1,22 @@
|
|||
extends GL_Animatable
|
||||
|
||||
var anim_tree: AnimationTree
|
||||
var blend_tree: AnimationNodeBlendTree
|
||||
|
||||
# Assuming this node has a child node with an AnimationPlayer
|
||||
func _ready():
|
||||
# Grab the AnimationPlayer from the first child
|
||||
var anim_player := get_child(0).get_node("AnimationPlayer") as AnimationPlayer
|
||||
|
||||
# Initialize the AnimationTree and set up the blend tree
|
||||
anim_tree = AnimationTree.new()
|
||||
add_child(anim_tree)
|
||||
|
||||
# Create and assign the root node for the blend tree
|
||||
anim_tree.tree_root = AnimationNodeBlendTree.new()
|
||||
anim_tree.active = true
|
||||
|
||||
blend_tree = anim_tree.tree_root as AnimationNodeBlendTree
|
||||
|
||||
func _sent_signals(anim_name: String, value: float):
|
||||
pass
|
1
Scripts/GL_Animatronic.gd.uid
Normal file
1
Scripts/GL_Animatronic.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://iqrmm33dxvui
|
50
Scripts/GL_Keystroke_Ramp.gd
Normal file
50
Scripts/GL_Keystroke_Ramp.gd
Normal file
|
@ -0,0 +1,50 @@
|
|||
extends GL_Node
|
||||
|
||||
var key_to_value = {
|
||||
KEY_1: 1.0 / 10,
|
||||
KEY_2: 2.0 / 10,
|
||||
KEY_3: 3.0 / 10,
|
||||
KEY_4: 4.0 / 10,
|
||||
KEY_5: 5.0 / 10,
|
||||
KEY_6: 6.0 / 10,
|
||||
KEY_7: 7.0 / 10,
|
||||
KEY_8: 8.0 / 10,
|
||||
KEY_9: 9.0 / 10,
|
||||
KEY_0: 1.0,
|
||||
}
|
||||
|
||||
var toggle_to_value = {
|
||||
KEY_1: 0,
|
||||
KEY_2: 1.0 / 9,
|
||||
KEY_3: 2.0 / 9,
|
||||
KEY_4: 3.0 / 9,
|
||||
KEY_5: 4.0 / 9,
|
||||
KEY_6: 5.0 / 9,
|
||||
KEY_7: 6.0 / 9,
|
||||
KEY_8: 7.0 / 9,
|
||||
KEY_9: 8.0 / 9,
|
||||
KEY_0: 1.0,
|
||||
}
|
||||
|
||||
func _ready():
|
||||
_set_title("Keystroke Ramp")
|
||||
_create_row("Output", null, 0.0, false, 0.0, 0)
|
||||
_create_row("Toggle", null, null, true, false, 0)
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
if rows["Toggle"]["pickValue"]:
|
||||
for key in toggle_to_value.keys():
|
||||
if Input.is_key_pressed(key) or Input.is_key_pressed(key + (KEY_KP_0 - KEY_0)):
|
||||
rows["Output"]["output"] = toggle_to_value[key]
|
||||
break
|
||||
else:
|
||||
var output_value := 0.0
|
||||
for key in key_to_value.keys():
|
||||
if Input.is_key_pressed(key) or Input.is_key_pressed(key + (KEY_KP_0 - KEY_0)):
|
||||
output_value = key_to_value[key]
|
||||
break
|
||||
rows["Output"]["output"] = output_value
|
||||
|
||||
_send_input("Output")
|
1
Scripts/GL_Keystroke_Ramp.gd.uid
Normal file
1
Scripts/GL_Keystroke_Ramp.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dhw0vlsb0bb8r
|
35
Scripts/GL_Keystrokes.gd
Normal file
35
Scripts/GL_Keystrokes.gd
Normal file
|
@ -0,0 +1,35 @@
|
|||
extends GL_Node
|
||||
|
||||
func _ready():
|
||||
_set_title("Keystrokes")
|
||||
_create_row("KEY #1",null,false,false,0.0,1)
|
||||
_create_row("KEY #2",null,false,false,0.0,1)
|
||||
_create_row("KEY #3",null,false,false,0.0,1)
|
||||
_create_row("KEY #4",null,false,false,0.0,1)
|
||||
_create_row("KEY #5",null,false,false,0.0,1)
|
||||
_create_row("KEY #6",null,false,false,0.0,1)
|
||||
_create_row("KEY #7",null,false,false,0.0,1)
|
||||
_create_row("KEY #8",null,false,false,0.0,1)
|
||||
_create_row("KEY #9",null,false,false,0.0,1)
|
||||
_create_row("KEY #0",null,false,false,0.0,1)
|
||||
pass
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
var key_map = {
|
||||
"KEY #1": KEY_1,
|
||||
"KEY #2": KEY_2,
|
||||
"KEY #3": KEY_3,
|
||||
"KEY #4": KEY_4,
|
||||
"KEY #5": KEY_5,
|
||||
"KEY #6": KEY_6,
|
||||
"KEY #7": KEY_7,
|
||||
"KEY #8": KEY_8,
|
||||
"KEY #9": KEY_9,
|
||||
"KEY #0": KEY_0,
|
||||
}
|
||||
|
||||
for key_name in key_map.keys():
|
||||
var is_pressed = Input.is_key_pressed(key_map[key_name]) or Input.is_key_pressed(key_map[key_name] + (KEY_KP_0 - KEY_0))
|
||||
rows[key_name]["output"] = is_pressed
|
||||
_send_input(key_name)
|
1
Scripts/GL_Keystrokes.gd.uid
Normal file
1
Scripts/GL_Keystrokes.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://e6v6exlrhtaq
|
18
Scripts/GL_Mix_Colors.gd
Normal file
18
Scripts/GL_Mix_Colors.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends GL_Node
|
||||
|
||||
func _ready():
|
||||
_set_title("Mix Colors")
|
||||
_create_row("Factor",0.0,Color.WHITE,false,null,0)
|
||||
_create_row("Color A",Color.RED,null,true,Color.RED,0)
|
||||
_create_row("Color B",Color.BLUE,null,true,Color.BLUE,0)
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
for key in rows:
|
||||
if rows[key]["picker"] == true && rows[key]["backConnected"] == false:
|
||||
rows[key]["input"] = rows[key]["pickValue"]
|
||||
|
||||
rows["Factor"]["output"] = rows["Color A"]["input"].lerp(rows["Color B"]["input"],rows["Factor"]["input"])
|
||||
_send_input("Factor")
|
1
Scripts/GL_Mix_Colors.gd.uid
Normal file
1
Scripts/GL_Mix_Colors.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dum3u4w3aa3s0
|
|
@ -1,4 +1,4 @@
|
|||
extends Panel
|
||||
extends PanelContainer
|
||||
class_name GL_Node
|
||||
var rows : Dictionary
|
||||
var uuid : int #REMEMBER TO SET THIS ON CREATION
|
||||
|
@ -31,7 +31,6 @@ func _update_visuals():
|
|||
for key in rows:
|
||||
var nodeRow = load("res://Scenes/Nodes/Node Row.tscn").instantiate()
|
||||
holder.add_child(nodeRow)
|
||||
nodeRow.name = str(key)
|
||||
(nodeRow.get_node("Label") as Label).text = str(key)
|
||||
var input = nodeRow.get_node("Input") as GL_Node_Point
|
||||
var output = nodeRow.get_node("Output") as GL_Node_Point
|
||||
|
@ -46,13 +45,14 @@ func _update_visuals():
|
|||
var slider = nodeRow.get_node("Pick Float") as HSlider
|
||||
slider.max_value = rows[key]["pickFloatMax"]
|
||||
slider.value = rows[key]["pickValue"]
|
||||
TYPE_BOOL:
|
||||
assignPick(nodeRow.get_node("Pick Bool"),str(key))
|
||||
(nodeRow.get_node("Pick Float") as ColorPickerButton).color = rows[key]["pickValue"]
|
||||
TYPE_COLOR:
|
||||
assignPick(nodeRow.get_node("Pick Color"),str(key))
|
||||
(nodeRow.get_node("Pick Float") as CheckButton).button_pressed = rows[key]["pickValue"]
|
||||
|
||||
(nodeRow.get_node("Pick Color") as ColorPickerButton).color = rows[key]["pickValue"]
|
||||
TYPE_BOOL:
|
||||
assignPick(nodeRow.get_node("Pick Bool"),str(key))
|
||||
(nodeRow.get_node("Pick Bool") as CheckButton).button_pressed = rows[key]["pickValue"]
|
||||
else:
|
||||
(nodeRow.get_node("Label") as Label).size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
|
||||
_set_inout_type(nodeRow.get_node("Input") as Button,rows[key]["input"])
|
||||
_set_inout_type(nodeRow.get_node("Output") as Button,rows[key]["output"])
|
||||
|
@ -63,12 +63,15 @@ func assignPick(pick:GL_Node_Picker,key:String):
|
|||
pick.valueName = key
|
||||
|
||||
func give_input_point_pos(name:String) -> Vector2:
|
||||
var holder = get_node("Margins").get_node("Holder").get_node(name)
|
||||
var holder = get_node("Margins").get_node("Holder")
|
||||
if holder == null:
|
||||
return global_position
|
||||
else:
|
||||
holder = holder.get_node("Input") as GL_Node_Point
|
||||
return holder.global_position + Vector2(holder.size.x/2,holder.size.y/2)
|
||||
for child in holder.get_children():
|
||||
if child.name != "Title" && (child.get_node("Label") as Label).text == name:
|
||||
holder = child.get_node("Input") as GL_Node_Point
|
||||
return holder.global_position + Vector2(holder.size.x/2,holder.size.y/2)
|
||||
return Vector2.ZERO
|
||||
|
||||
func _set_inout_type(label:Button, value):
|
||||
match typeof(value):
|
||||
|
@ -93,7 +96,10 @@ func _create_row(name:String,input,output,picker:bool,pickDefault,pickFloatMaxim
|
|||
|
||||
func _recieve_input(inputName:String,value):
|
||||
if rows.has(inputName):
|
||||
rows[inputName]["input"] = value
|
||||
if typeof(rows[inputName]["input"]) == TYPE_FLOAT && typeof(value) == TYPE_BOOL:
|
||||
rows[inputName]["input"] = float(value)
|
||||
else:
|
||||
rows[inputName]["input"] = value
|
||||
|
||||
func _send_input(output_name: String):
|
||||
if not rows.has(output_name):
|
||||
|
@ -120,8 +126,9 @@ func _create_connection(target:GL_Node,input_name:String,output_name:String):
|
|||
return
|
||||
|
||||
if typeof(rows[output_name].get("output", null)) != typeof(target.rows[input_name].get("input",null)):
|
||||
print("Type mismatch: cannot connect " + output_name + " to " + target.name)
|
||||
return
|
||||
if !(typeof(rows[output_name].get("output", null)) == TYPE_BOOL && typeof(target.rows[input_name].get("input",null)) == TYPE_FLOAT):
|
||||
print("Type mismatch: cannot connect " + output_name + " to " + target.name)
|
||||
return
|
||||
|
||||
var thenew = {
|
||||
"target": target,
|
||||
|
|
21
Scripts/GL_Node_Map.gd
Normal file
21
Scripts/GL_Node_Map.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends Control
|
||||
var background:TextureRect
|
||||
|
||||
func _ready():
|
||||
visible = false
|
||||
background = get_node("Background")
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
match(event.keycode):
|
||||
KEY_ESCAPE:
|
||||
visible = not visible
|
||||
if visible:
|
||||
background.self_modulate.a = 1
|
||||
KEY_TAB:
|
||||
background.self_modulate.a = abs(background.self_modulate.a - 1)
|
||||
|
||||
if visible:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
1
Scripts/GL_Node_Map.gd.uid
Normal file
1
Scripts/GL_Node_Map.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://i4p62x8fnqpn
|
|
@ -13,7 +13,8 @@ func _process(delta):
|
|||
if dragging:
|
||||
if previewLine == null:
|
||||
previewLine = _create_line()
|
||||
previewLine.points[1] = get_viewport().get_mouse_position() - previewLine.global_position
|
||||
previewLine.points[0] = global_position + Vector2(size.x / 2, size.y / 2)
|
||||
previewLine.points[1] = get_viewport().get_mouse_position()# - previewLine.global_position
|
||||
|
||||
var connections = mainNode.rows[valueName].get("connections",[])
|
||||
if connections != []:
|
||||
|
@ -30,7 +31,8 @@ func _process(delta):
|
|||
child.default_color = Color.BLACK
|
||||
TYPE_COLOR:
|
||||
child.default_color = output
|
||||
child.points[1] = (connections[iter]["target"] as GL_Node).give_input_point_pos(connections[iter]["input_name"]) - child.global_position
|
||||
child.points[0] = global_position + Vector2(size.x / 2, size.y / 2)
|
||||
child.points[1] = (connections[iter]["target"] as GL_Node).give_input_point_pos(connections[iter]["input_name"])# - child.global_position
|
||||
iter += 1
|
||||
|
||||
func _create_line() -> Line2D:
|
||||
|
@ -40,9 +42,10 @@ func _create_line() -> Line2D:
|
|||
previewLine.default_color = Color.WHITE
|
||||
previewLine.add_point(Vector2.ZERO)
|
||||
previewLine.add_point(Vector2.ZERO)
|
||||
previewLine.points[0] = Vector2(size.x / 2, size.y / 2)
|
||||
previewLine.begin_cap_mode = Line2D.LINE_CAP_ROUND
|
||||
previewLine.end_cap_mode = Line2D.LINE_CAP_ROUND
|
||||
previewLine.antialiased = true
|
||||
previewLine.top_level = true
|
||||
add_child(previewLine)
|
||||
return previewLine
|
||||
|
||||
|
|
29
Scripts/GL_Output.gd
Normal file
29
Scripts/GL_Output.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
extends GL_Node
|
||||
|
||||
@export var identification : String
|
||||
@export var names : PackedStringArray
|
||||
@export var types : PackedStringArray
|
||||
|
||||
func _ready():
|
||||
_set_title(identification)
|
||||
for i in names.size():
|
||||
match(types[i].to_lower()):
|
||||
"float":
|
||||
_create_row(str(names[i]),0.01,null,true,0.5,1)
|
||||
"color":
|
||||
_create_row(str(names[i]),Color.WHITE,null,true,Color.WHITE,0)
|
||||
"bool":
|
||||
_create_row(str(names[i]),false,null,true,false,0)
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
for key in rows:
|
||||
if rows[key]["picker"] == true && rows[key]["backConnected"] == false:
|
||||
rows[key]["input"] = rows[key]["pickValue"]
|
||||
|
||||
for node in get_tree().get_nodes_in_group(identification):
|
||||
if node is GL_Animatable:
|
||||
for key in rows:
|
||||
node._sent_signals(key,rows[key]["input"])
|
1
Scripts/GL_Output.gd.uid
Normal file
1
Scripts/GL_Output.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://t8bsiegtsiwo
|
|
@ -1,14 +1,21 @@
|
|||
extends GL_Node
|
||||
var rng : RandomNumberGenerator
|
||||
var timing : float
|
||||
|
||||
func _ready():
|
||||
_set_title("Random")
|
||||
_create_row("Output",null,0.0,false,null,0)
|
||||
_create_row("Time",0.01,null,true,0.01,5)
|
||||
rng = RandomNumberGenerator.new()
|
||||
rng.seed = Time.get_ticks_msec()
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
rows["Output"]["output"] = rng.randf()
|
||||
if rows["Time"]["picker"] == true && rows["Time"]["backConnected"] == false:
|
||||
rows["Time"]["input"] = rows["Time"]["pickValue"]
|
||||
timing -= delta
|
||||
if timing <= 0:
|
||||
timing = rows["Time"]["input"]
|
||||
rows["Output"]["output"] = rng.randf()
|
||||
_send_input("Output")
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
extends Control
|
||||
|
||||
var rows : Dictionary = {"Sine":99,"Random":99,"Float":99}
|
||||
var rows : Dictionary = {
|
||||
"Sine":99,
|
||||
"Random":99,
|
||||
"Float":99,
|
||||
"Chica":1,
|
||||
"ChicaSpot":1,
|
||||
"Keystrokes":1,
|
||||
"Keystroke Ramp":1,
|
||||
"Mix Colors":1,
|
||||
}
|
||||
var searching : bool
|
||||
var lastMousePos : Vector2
|
||||
|
||||
|
@ -39,7 +48,7 @@ func _set_rows():
|
|||
|
||||
func _create_node(name:String):
|
||||
var node = load("res://Scenes/Node Types/" + name + ".tscn").instantiate()
|
||||
get_tree().root.add_child(node)
|
||||
get_parent().add_child(node)
|
||||
node = (node as Control).get_child(0) as GL_Node
|
||||
node.position = lastMousePos
|
||||
node._create_uuid()
|
||||
|
|
|
@ -3,12 +3,12 @@ extends GL_Node
|
|||
func _ready():
|
||||
_set_title("Sine")
|
||||
_create_row("Output",null,0.0,false,null,0)
|
||||
_create_row("Length",0.01,null,true,0.01,0.05)
|
||||
_create_row("Time",0.01,null,true,0.01,0.05)
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
if rows["Length"]["picker"] == true && rows["Length"]["backConnected"] == false:
|
||||
rows["Length"]["input"] = rows["Length"]["pickValue"]
|
||||
rows["Output"]["output"] = (sin(Time.get_ticks_msec() * rows["Length"].get("input",1)) / 2) + 0.5
|
||||
if rows["Time"]["picker"] == true && rows["Time"]["backConnected"] == false:
|
||||
rows["Time"]["input"] = rows["Time"]["pickValue"]
|
||||
rows["Output"]["output"] = (sin(Time.get_ticks_msec() * rows["Time"].get("input",1)) / 2) + 0.5
|
||||
_send_input("Output")
|
||||
|
|
20
Scripts/GL_Spotlight.gd
Normal file
20
Scripts/GL_Spotlight.gd
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends GL_Animatable
|
||||
var light:SpotLight3D
|
||||
@export var canChangeColor:bool = false
|
||||
@export var canChangeSize:bool = false
|
||||
@export var energyMultiplier:float = 500
|
||||
|
||||
func _ready():
|
||||
light = self.get_parent()
|
||||
|
||||
func _sent_signals(signal_ID:String,the_signal):
|
||||
match(signal_ID):
|
||||
"intensity":
|
||||
light.light_energy = the_signal * energyMultiplier
|
||||
"color":
|
||||
if canChangeColor:
|
||||
light.light_color = the_signal
|
||||
"size":
|
||||
if canChangeSize:
|
||||
light.spot_angle = the_signal * 90
|
||||
pass
|
1
Scripts/GL_Spotlight.gd.uid
Normal file
1
Scripts/GL_Spotlight.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://c5uawj66escut
|
146
Scripts/freecam.gd
Normal file
146
Scripts/freecam.gd
Normal file
|
@ -0,0 +1,146 @@
|
|||
extends Camera3D
|
||||
|
||||
## Camera with flying script attached to it.
|
||||
class_name Freecam3D
|
||||
|
||||
##
|
||||
## Camera with toggleable freecam mode for prototyping when creating levels, shaders, lighting, etc.
|
||||
##
|
||||
## Usage: Run your game, press <TAB> and fly around freely. Uses Minecraft-like controls.
|
||||
##
|
||||
|
||||
## Customize your own toggle key to avoid collisions with your current mappings.
|
||||
@export var toggle_key: Key = KEY_TAB
|
||||
## Speed up / down by scrolling the mouse whell down / up
|
||||
@export var invert_speed_controls: bool = false
|
||||
|
||||
@export var overlay_text: bool = true
|
||||
|
||||
## Pivot node for camera looking around
|
||||
@onready var pivot := Node3D.new()
|
||||
## Main parent for camera overlay.
|
||||
@onready var screen_overlay := VBoxContainer.new()
|
||||
## Container for the chat-like event log.
|
||||
@onready var event_log := VBoxContainer.new()
|
||||
|
||||
const MAX_SPEED := 0.25
|
||||
const MIN_SPEED := 0.01
|
||||
const ACCELERATION := 0.1
|
||||
const MOUSE_SENSITIVITY := 0.002
|
||||
|
||||
## Whether or not the camera can move.
|
||||
var movement_active := false:
|
||||
set(val):
|
||||
movement_active = val
|
||||
display_message("[Movement ON]" if movement_active else "[Movement OFF]")
|
||||
|
||||
## The current maximum speed. Lower or higher it by scrolling the mouse wheel.
|
||||
var target_speed := MIN_SPEED
|
||||
## Movement velocity.
|
||||
var velocity := Vector3.ZERO
|
||||
|
||||
|
||||
## Sets up pivot and UI overlay elements.
|
||||
func _setup_nodes() -> void:
|
||||
self.add_sibling(pivot)
|
||||
pivot.position = position
|
||||
pivot.rotation = rotation
|
||||
pivot.name = "FreecamPivot"
|
||||
self.reparent(pivot)
|
||||
self.position = Vector3.ZERO
|
||||
self.rotation = Vector3.ZERO
|
||||
# UI stuff
|
||||
screen_overlay.add_theme_constant_override("Separation", 8)
|
||||
self.add_child(screen_overlay)
|
||||
screen_overlay.add_child(_make_label("Debug Camera"))
|
||||
screen_overlay.add_spacer(false)
|
||||
|
||||
screen_overlay.add_child(event_log)
|
||||
screen_overlay.visible = overlay_text
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_nodes.call_deferred()
|
||||
_add_keybindings()
|
||||
movement_active = true
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
if Input.is_action_just_released("__debug_camera_toggle"):
|
||||
movement_active = not movement_active
|
||||
|
||||
if movement_active:
|
||||
var dir = Vector3.ZERO
|
||||
if Input.is_action_pressed("__debug_camera_forward"): dir.z -= 1
|
||||
if Input.is_action_pressed("__debug_camera_back"): dir.z += 1
|
||||
if Input.is_action_pressed("__debug_camera_left"): dir.x -= 1
|
||||
if Input.is_action_pressed("__debug_camera_right"): dir.x += 1
|
||||
if Input.is_action_pressed("__debug_camera_up"): dir.y += 1
|
||||
if Input.is_action_pressed("__debug_camera_down"): dir.y -= 1
|
||||
|
||||
dir = dir.normalized()
|
||||
dir = dir.rotated(Vector3.UP, pivot.rotation.y)
|
||||
|
||||
velocity = lerp(velocity, dir * target_speed, ACCELERATION)
|
||||
pivot.position += velocity
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if movement_active:
|
||||
# Turn around
|
||||
if event is InputEventMouseMotion:
|
||||
pivot.rotate_y(-event.relative.x * MOUSE_SENSITIVITY)
|
||||
rotate_x(-event.relative.y * MOUSE_SENSITIVITY)
|
||||
rotation.x = clamp(rotation.x, -PI/2, PI/2)
|
||||
|
||||
var speed_up = func():
|
||||
target_speed = clamp(target_speed + 0.015, MIN_SPEED, MAX_SPEED)
|
||||
display_message("[Speed up] " + str(target_speed))
|
||||
|
||||
var slow_down = func():
|
||||
target_speed = clamp(target_speed - 0.015, MIN_SPEED, MAX_SPEED)
|
||||
display_message("[Slow down] " + str(target_speed))
|
||||
|
||||
# Speed up and down with the mouse wheel
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
|
||||
slow_down.call() if invert_speed_controls else speed_up.call()
|
||||
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
|
||||
speed_up.call() if invert_speed_controls else slow_down.call()
|
||||
|
||||
|
||||
## Pushes new message label into "chat" and removes the old ones if necessary
|
||||
func display_message(text: String) -> void:
|
||||
while event_log.get_child_count() >= 3:
|
||||
event_log.remove_child(event_log.get_child(0))
|
||||
|
||||
event_log.add_child(_make_label(text))
|
||||
|
||||
|
||||
func _make_label(text: String) -> Label:
|
||||
var l = Label.new()
|
||||
l.text = text
|
||||
return l
|
||||
|
||||
|
||||
func _add_keybindings() -> void:
|
||||
var actions = InputMap.get_actions()
|
||||
if "__debug_camera_forward" not in actions: _add_key_input_action("__debug_camera_forward", KEY_W)
|
||||
if "__debug_camera_back" not in actions: _add_key_input_action("__debug_camera_back", KEY_S)
|
||||
if "__debug_camera_left" not in actions: _add_key_input_action("__debug_camera_left", KEY_A)
|
||||
if "__debug_camera_right" not in actions: _add_key_input_action("__debug_camera_right", KEY_D)
|
||||
if "__debug_camera_up" not in actions: _add_key_input_action("__debug_camera_up", KEY_E)
|
||||
if "__debug_camera_down" not in actions: _add_key_input_action("__debug_camera_down", KEY_Q)
|
||||
if "__debug_camera_toggle" not in actions: _add_key_input_action("__debug_camera_toggle", toggle_key)
|
||||
|
||||
|
||||
func _add_key_input_action(name: String, key: Key) -> void:
|
||||
var ev = InputEventKey.new()
|
||||
ev.physical_keycode = key
|
||||
|
||||
InputMap.add_action(name)
|
||||
InputMap.action_add_event(name, ev)
|
1
Scripts/freecam.gd.uid
Normal file
1
Scripts/freecam.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://8vyuhyx0xogt
|
Loading…
Add table
Add a link
Reference in a new issue