You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
GDScript
56 lines
1.6 KiB
GDScript
extends MeshInstance3D
|
|
|
|
@export var f := 1.0
|
|
@export var z := 0.5
|
|
@export var r := 2.0
|
|
@export var target_path: NodePath
|
|
@export var f_label_path: NodePath
|
|
@export var z_label_path: NodePath
|
|
@export var r_label_path: NodePath
|
|
|
|
@onready var second_order_dynamics := SecondOrderDynamics.new(f, z, r, global_position)
|
|
@onready var target_node: Node3D = get_node(target_path)
|
|
@onready var f_label_node: Label = get_node(f_label_path)
|
|
@onready var z_label_node: Label = get_node(z_label_path)
|
|
@onready var r_label_node: Label = get_node(r_label_path)
|
|
|
|
func _ready():
|
|
process_mode = Node.PROCESS_MODE_ALWAYS
|
|
|
|
func _input(event):
|
|
if event.is_action_pressed("inc_f"):
|
|
f += 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
if event.is_action_pressed("dec_f"):
|
|
f -= 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
if event.is_action_pressed("inc_z"):
|
|
z += 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
if event.is_action_pressed("dec_z"):
|
|
z -= 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
if event.is_action_pressed("inc_r"):
|
|
r += 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
if event.is_action_pressed("dec_r"):
|
|
r -= 0.1
|
|
second_order_dynamics = SecondOrderDynamics.new(f, z, r, global_position)
|
|
|
|
func _process(delta):
|
|
global_position = second_order_dynamics.update(delta, target_node.global_position)
|
|
|
|
if f_label_node:
|
|
f_label_node.text = "f = %.3f" % [f]
|
|
|
|
if z_label_node:
|
|
z_label_node.text = "z = %.3f" % [z]
|
|
|
|
if r_label_node:
|
|
r_label_node.text = "r = %.3f" % [r]
|