Add some base classes for body building
This commit is contained in:
parent
993a6c0ca2
commit
ee8d7b789d
@ -13,7 +13,7 @@ func _ready():
|
||||
func arm_collided(body):
|
||||
if body.name != "Arm":
|
||||
print("Entered")
|
||||
apply_impulse(area.transform.origin, Vector3.UP * 10.0)
|
||||
apply_impulse(area.transform.origin, -transform.basis.y * 10.0)
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
|
@ -44,10 +44,10 @@ bind/3/pose = Transform( 1, 0, 0, 0, 0, -1, 0, 1, 0, 2.23781e-16, -8.54317, 0.00
|
||||
bind/4/bone = 4
|
||||
bind/4/pose = Transform( 1, 0, -2.38419e-07, -2.84217e-14, 1, -1.19209e-07, 2.38419e-07, 0, 1, -1.18891e-06, -1.48879, 4.98664 )
|
||||
|
||||
[sub_resource type="SphereShape" id=7]
|
||||
[sub_resource type="SphereShape" id=5]
|
||||
radius = 0.713315
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
[sub_resource type="Animation" id=6]
|
||||
length = 0.583333
|
||||
tracks/0/type = "transform"
|
||||
tracks/0/path = NodePath("Armature/Skeleton:bone_2")
|
||||
@ -85,7 +85,7 @@ tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/keys = PoolRealArray( 0, 1, 5.68434e-14, 0, 0, -9.0278e-36, -7.10543e-15, 4.23516e-22, 1, 1, 1, 1, 0.583333, 1, 5.68434e-14, 0, 0, -9.0278e-36, -7.10543e-15, 4.23516e-22, 1, 1, 1, 1 )
|
||||
|
||||
[sub_resource type="SphereShape" id=6]
|
||||
[sub_resource type="SphereShape" id=7]
|
||||
|
||||
[node name="Arm" type="RigidBody"]
|
||||
script = ExtResource( 1 )
|
||||
@ -117,7 +117,7 @@ bones/2/name = "bone_2"
|
||||
bones/2/parent = 1
|
||||
bones/2/rest = Transform( 1, -5.10854e-24, -9.60376e-26, 5.10525e-24, 0.999765, -0.0216853, 2.06795e-25, 0.0216853, 0.999765, 2.71197e-23, 2.61421, -1.86265e-09 )
|
||||
bones/2/enabled = true
|
||||
bones/2/bound_children = [ ]
|
||||
bones/2/bound_children = [ NodePath("BoneAttachment") ]
|
||||
bones/3/name = "hand_ik"
|
||||
bones/3/parent = -1
|
||||
bones/3/rest = Transform( 1, 0, 0, 0, 0, 1, 0, -1, 0, -2.23781e-16, -0.00782001, -5.99735 )
|
||||
@ -135,17 +135,17 @@ skin = SubResource( 4 )
|
||||
material/0 = null
|
||||
|
||||
[node name="BoneAttachment" type="BoneAttachment" parent="Armature/Skeleton"]
|
||||
transform = Transform( 1, -1.97986e-23, -2.67322e-24, 2.57758e-24, -8.3819e-08, 1, 3.22115e-23, -1, -8.3819e-08, -2.23781e-16, -0.00782044, -5.05441 )
|
||||
transform = Transform( 1, -1.98031e-23, -2.87996e-24, 2.78437e-24, -8.3819e-08, 1, 3.22164e-23, -1, -8.3819e-08, -2.23781e-16, -0.00782044, -5.05441 )
|
||||
bone_name = "bone_2"
|
||||
|
||||
[node name="TouchArea" type="Area" parent="Armature/Skeleton/BoneAttachment"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="Armature/Skeleton/BoneAttachment/TouchArea"]
|
||||
shape = SubResource( 7 )
|
||||
shape = SubResource( 5 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/ArmatureAction001 = SubResource( 5 )
|
||||
anims/ArmatureAction001 = SubResource( 6 )
|
||||
|
||||
[node name="CollisionShape2" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, -1.97986e-23, -2.67322e-24, 2.57758e-24, -8.3819e-08, 1, 3.22115e-23, -1, -8.3819e-08, -2.23781e-16, -0.00782044, -7.60024 )
|
||||
shape = SubResource( 6 )
|
||||
shape = SubResource( 7 )
|
||||
|
17
Ingame/BodyParts/BodyBase.gd
Normal file
17
Ingame/BodyParts/BodyBase.gd
Normal file
@ -0,0 +1,17 @@
|
||||
extends Spatial
|
||||
class_name BodyBase
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
6
Ingame/BodyParts/BodyBase.tscn
Normal file
6
Ingame/BodyParts/BodyBase.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Ingame/BodyParts/BodyBase.gd" type="Script" id=1]
|
||||
|
||||
[node name="BodyBase" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
21
Ingame/BodyParts/BodyPart.gd
Normal file
21
Ingame/BodyParts/BodyPart.gd
Normal file
@ -0,0 +1,21 @@
|
||||
extends Spatial
|
||||
class_name BodyPart
|
||||
|
||||
# Must be the direct child of a BodyBase
|
||||
|
||||
|
||||
onready var base = get_parent()
|
||||
onready var physics_shape = get_node("CollisionShape")
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
assert(base is BodyBase)
|
||||
|
||||
base.add_child(physics_shape)
|
||||
remove_child(physics_shape)
|
||||
|
||||
|
||||
# Do something with the base
|
||||
func action():
|
||||
pass
|
8
Ingame/BodyParts/BodyPart.tscn
Normal file
8
Ingame/BodyParts/BodyPart.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Ingame/BodyParts/BodyPart.gd" type="Script" id=1]
|
||||
|
||||
[node name="BodyPart" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
18
Ingame/BodyParts/PushingBodyPart.gd
Normal file
18
Ingame/BodyParts/PushingBodyPart.gd
Normal file
@ -0,0 +1,18 @@
|
||||
extends BodyPart
|
||||
|
||||
|
||||
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
|
9
Ingame/BodyParts/PushingBodyPart.tscn
Normal file
9
Ingame/BodyParts/PushingBodyPart.tscn
Normal file
@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Ingame/BodyParts/BodyPart.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Ingame/BodyParts/PushingBodyPart.gd" type="Script" id=2]
|
||||
|
||||
[node name="PushingBodyPart" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="TouchArea" type="Area" parent="." index="1"]
|
@ -8,9 +8,20 @@
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_classes=[ {
|
||||
"base": "Spatial",
|
||||
"class": "BodyBase",
|
||||
"language": "GDScript",
|
||||
"path": "res://Ingame/BodyParts/BodyBase.gd"
|
||||
}, {
|
||||
"base": "Spatial",
|
||||
"class": "BodyPart",
|
||||
"language": "GDScript",
|
||||
"path": "res://Ingame/BodyParts/BodyPart.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
|
||||
"BodyBase": "",
|
||||
"BodyPart": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
Loading…
x
Reference in New Issue
Block a user