30 lines
551 B
GDScript
30 lines
551 B
GDScript
extends Spatial
|
|
class_name BodyPart
|
|
|
|
# Must be the direct child of a BodyBase
|
|
|
|
|
|
onready var base = get_parent()
|
|
onready var physics_shape = get_node("PartCollider")
|
|
|
|
export(int) var key
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
assert(base is BodyBase)
|
|
|
|
remove_child(physics_shape)
|
|
base.call_deferred("add_child", physics_shape)
|
|
|
|
|
|
func _unhandled_input(event):
|
|
if event is InputEventKey:
|
|
if event.pressed and event.scancode == key:
|
|
action()
|
|
|
|
|
|
# Do something with the base
|
|
func action():
|
|
pass
|