Add basic arm with new structure
This commit is contained in:
parent
ee8d7b789d
commit
5e9fcc38d2
@ -1,26 +1,16 @@
|
||||
extends RigidBody
|
||||
extends "res://Ingame/BodyParts/PushingBodyPart.gd"
|
||||
|
||||
|
||||
onready var anim = get_node("AnimationPlayer")
|
||||
onready var skeleton = get_node("Armature/Skeleton")
|
||||
onready var area = get_node("Armature/Skeleton/BoneAttachment/TouchArea")
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
func _ready():
|
||||
area.connect("body_entered", self, "arm_collided")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func arm_collided(body):
|
||||
if body.name != "Arm":
|
||||
print("Entered")
|
||||
apply_impulse(area.transform.origin, -transform.basis.y * 10.0)
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventKey:
|
||||
if event.pressed and event.scancode == KEY_A:
|
||||
play()
|
||||
|
||||
|
||||
func play():
|
||||
anim.play("ArmatureAction001")
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,20 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Ingame/BodyParts/BodyBase.gd" type="Script" id=1]
|
||||
|
||||
[node name="BodyBase" type="Spatial"]
|
||||
[sub_resource type="CapsuleMesh" id=1]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape" id=2]
|
||||
points = PoolVector3Array( -0.976555, -0.115531, 0.676252, -0.97477, 0.129786, 0.675025, -0.972729, 0.170391, -0.632762, -0.930705, -0.318757, -0.672787, -0.884938, -0.438707, 0.628485, -0.852838, 0.129915, 1.00335, -0.849191, 0.496531, -0.672869, -0.803433, 0.574508, 0.628223, -0.768518, 0.129545, -1.12264, -0.725725, -0.3591, 1.07922, -0.721015, -0.680519, -0.586622, -0.683166, 0.534891, 0.994835, -0.648419, -0.115498, -1.24963, -0.562995, -0.807204, 0.672059, -0.526953, 0.130336, 1.33554, -0.480814, 0.617232, -1.11842, -0.479804, 0.859538, -0.669774, -0.479803, 0.859536, 0.669773, -0.440687, -0.603552, -1.16064, -0.43878, -0.884893, -0.628588, -0.317763, -0.885919, 0.832213, -0.282246, -0.240683, 1.42608, -0.198218, 0.335642, -1.41718, -0.197532, -0.975449, 0.552572, -0.15707, 0.581984, 1.29355, -0.156757, -0.525388, -1.33211, -0.156757, -0.525388, 1.33211, -0.117117, -0.199568, -1.46926, -0.116847, 0.213598, 1.46606, -0.11591, -0.976507, -0.67622, -0.115807, 0.826041, -1.04422, -0.115565, 0.988039, -0.551618, -0.0747357, 0.947977, 0.797463, 0.12956, -0.768424, -1.12278, 0.129786, -0.97477, 0.675025, 0.171135, 0.58102, -1.29182, 0.172267, 0.172267, -1.46605, 0.2128, -0.321832, 1.41923, 0.25284, 0.825812, -1.0032, 0.253122, 0.949838, 0.676403, 0.29257, -0.686201, 1.16252, 0.332014, 0.94129, -0.507643, 0.33379, 0.61975, 1.20479, 0.335646, -0.19822, -1.41719, 0.378044, -0.0339178, 1.42212, 0.413277, -0.845586, -0.832511, 0.453569, -0.885709, -0.54779, 0.496551, -0.441258, -1.24375, 0.496608, -0.849134, 0.672975, 0.572962, 0.775053, 0.747599, 0.577133, 0.332796, -1.24188, 0.654399, 0.735187, -0.667508, 0.700886, 0.25188, 1.16319, 0.736328, -0.560023, 0.871037, 0.742227, -0.237757, -1.12308, 0.742233, -0.237759, 1.12309, 0.85642, 0.492308, 0.626846, 0.856435, 0.492317, -0.626858, 0.859536, -0.479803, -0.669773, 0.866929, 0.170866, -0.962149, 0.899981, -0.398467, 0.669636, 0.990148, -0.0336554, -0.593795, 0.990984, 0.0890012, 0.553274, 0.991375, 0.00714278, 0.594536 )
|
||||
|
||||
[node name="BodyBase" type="RigidBody"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = null
|
||||
|
||||
[node name="BaseCollider" type="CollisionShape" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
|
||||
shape = SubResource( 2 )
|
||||
|
@ -5,15 +5,23 @@ class_name BodyPart
|
||||
|
||||
|
||||
onready var base = get_parent()
|
||||
onready var physics_shape = get_node("CollisionShape")
|
||||
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)
|
||||
|
||||
base.add_child(physics_shape)
|
||||
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
|
||||
|
@ -5,4 +5,4 @@
|
||||
[node name="BodyPart" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
[node name="PartCollider" type="CollisionShape" parent="."]
|
||||
|
@ -1,5 +1,5 @@
|
||||
extends BodyPart
|
||||
|
||||
class_name PushingBodyPart
|
||||
|
||||
onready var touch_area = get_node("TouchArea")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user