Move body parts to outer folder
This commit is contained in:
1 parent
1a0e09c1ba
commit
c8acaf0988
12 files changed
+18
-13
No files matched your search
@@ -0,0 +1,22 @@
|
||||
extends PushingBodyPart
|
||||
|
||||
|
||||
onready var anim = get_node("Mesh/AnimationPlayer")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func action():
|
||||
anim.play("ArmatureAction001")
|
||||
|
||||
|
||||
func push(body):
|
||||
# TODO: Hardcoded values - maybe try to generalize
|
||||
base.apply_impulse(transform.basis.xform(Vector3(0.0, 0.0, -3.0)), base.transform.basis.y * 10.0)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
@@ -0,0 +1,36 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://BodyParts/PushingBodyPart.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2]
|
||||
[ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3]
|
||||
|
||||
|
||||
[sub_resource type="SphereShape" id=1]
|
||||
|
||||
[sub_resource type="SphereShape" id=2]
|
||||
radius = 0.591769
|
||||
|
||||
[node name="Arm" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="PartCollider" parent="." index="0"]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Mesh" parent="." index="1" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"]
|
||||
transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 )
|
||||
bone_name = "bone_2"
|
||||
|
||||
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
|
||||
remote_path = NodePath("../../../../../TouchArea")
|
||||
|
||||
[node name="TouchArea" parent="." index="2"]
|
||||
transform = Transform( 1, -1.98292e-23, -3.18966e-24, 6.71348e-24, -9.49949e-08, 1, -2.07636e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -7.60024 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
|
||||
transform = Transform( 1, 2.98291e-24, -1.98247e-23, -2.07684e-23, -9.49949e-08, -1, -6.50669e-24, 1, -9.49949e-08, 2.23781e-16, 0.399765, 0.00782054 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[editable path="Mesh"]
|
||||
@@ -0,0 +1,14 @@
|
||||
extends Spatial
|
||||
class_name BodyBase
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
@@ -0,0 +1,52 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1]
|
||||
|
||||
|
||||
[sub_resource type="CapsuleMesh" id=1]
|
||||
|
||||
[sub_resource type="CapsuleShape" id=2]
|
||||
|
||||
[sub_resource type="SphereMesh" id=3]
|
||||
|
||||
[sub_resource type="SphereShape" id=4]
|
||||
|
||||
[sub_resource type="SphereShape" id=5]
|
||||
|
||||
[node name="Torso" type="RigidBody"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="TorsoMesh" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = null
|
||||
|
||||
[node name="TorsoCollider" type="CollisionShape" parent="."]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="FrontLeft" type="Spatial" parent="."]
|
||||
transform = Transform( 1.62921e-07, -5.30863e-14, -1, -3.25841e-07, -1, 0, -1, 3.25841e-07, -1.62921e-07, 0.6, 0, 1 )
|
||||
|
||||
[node name="FrontLeftAttachMent" type="MeshInstance" parent="FrontLeft"]
|
||||
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
||||
mesh = SubResource( 3 )
|
||||
material/0 = null
|
||||
|
||||
[node name="Area" type="Area" parent="FrontLeft"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="FrontLeft/Area"]
|
||||
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||
shape = SubResource( 4 )
|
||||
|
||||
[node name="FrontRight" type="Spatial" parent="."]
|
||||
transform = Transform( 1.62921e-07, -5.30863e-14, 1, -3.25841e-07, -1, 0, 1, -3.25841e-07, -1.62921e-07, -0.6, 0, 1 )
|
||||
|
||||
[node name="FrontRightAttachMent" type="MeshInstance" parent="FrontRight"]
|
||||
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
||||
mesh = SubResource( 3 )
|
||||
material/0 = null
|
||||
|
||||
[node name="Area" type="Area" parent="FrontRight"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="FrontRight/Area"]
|
||||
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||
shape = SubResource( 5 )
|
||||
@@ -0,0 +1,43 @@
|
||||
extends Spatial
|
||||
class_name BodyPart
|
||||
|
||||
# Must be the direct child of an AttachmentPoint of the BodyBase
|
||||
|
||||
|
||||
onready var base = get_parent().get_parent()
|
||||
onready var physics_shape = get_node("PartCollider")
|
||||
|
||||
export(int) var key
|
||||
|
||||
var setup_done = false
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
assert(base is BodyBase)
|
||||
|
||||
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# We do this here because we want the whole tree to really be done instancing
|
||||
if not setup_done:
|
||||
var translation = physics_shape.global_transform.basis * physics_shape.translation
|
||||
|
||||
remove_child(physics_shape)
|
||||
base.add_child(physics_shape)
|
||||
|
||||
physics_shape.translation = translation
|
||||
|
||||
setup_done = true
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.pressed and event.scancode == key:
|
||||
action()
|
||||
|
||||
|
||||
# Do something with the base
|
||||
func action():
|
||||
pass
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://BodyParts/BodyPart.gd" type="Script" id=1]
|
||||
|
||||
|
||||
[node name="BodyPart" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="PartCollider" type="CollisionShape" parent="."]
|
||||
@@ -0,0 +1,18 @@
|
||||
extends BodyPart
|
||||
class_name PushingBodyPart
|
||||
|
||||
onready var touch_area = get_node("TouchArea")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
touch_area.connect("body_entered", self, "_on_touch_area_entered")
|
||||
|
||||
|
||||
func _on_touch_area_entered(body):
|
||||
if body.name != base.name:
|
||||
push(body)
|
||||
|
||||
|
||||
func push(body):
|
||||
pass
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://BodyParts/BodyPart.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://BodyParts/PushingBodyPart.gd" type="Script" id=2]
|
||||
|
||||
|
||||
[node name="PushingBodyPart" index="0" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="TouchArea" type="Area" parent="." index="1"]
|
||||
@@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[sub_resource type="CubeMesh" id=1]
|
||||
|
||||
[sub_resource type="BoxShape" id=2]
|
||||
|
||||
[node name="Torso" type="RigidBody"]
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = null
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
shape = SubResource( 2 )
|
||||
Reference in new issue
Block a user