Fix collision shape offset of body part
This commit is contained in:
parent
a773e5900d
commit
153d545550
@ -15,7 +15,7 @@ func action():
|
|||||||
|
|
||||||
func push(body):
|
func push(body):
|
||||||
# TODO: Hardcoded values - maybe try to generalize
|
# 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)
|
base.apply_impulse(transform.basis.xform(Vector3(-3.0, 0.0, 0.0)), base.transform.basis.y * 10.0)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta: float) -> void:
|
#func _process(delta: float) -> void:
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
[ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2]
|
[ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3]
|
[ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="SphereShape" id=1]
|
[sub_resource type="SphereShape" id=1]
|
||||||
|
|
||||||
[sub_resource type="SphereShape" id=2]
|
[sub_resource type="SphereShape" id=2]
|
||||||
@ -19,15 +18,18 @@ shape = SubResource( 1 )
|
|||||||
|
|
||||||
[node name="Mesh" parent="." index="1" instance=ExtResource( 2 )]
|
[node name="Mesh" parent="." index="1" instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Sphere" parent="Mesh" index="0"]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"]
|
[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 )
|
transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 )
|
||||||
bone_name = "bone_2"
|
bone_name = "bone_2"
|
||||||
|
|
||||||
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
|
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
|
||||||
remote_path = NodePath("../../../../../TouchArea")
|
remote_path = NodePath("../../../../../TouchArea")
|
||||||
|
|
||||||
[node name="TouchArea" parent="." index="2"]
|
[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 )
|
transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -7.60024 )
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
|
[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 )
|
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 )
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
[ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1]
|
[ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleMesh" id=1]
|
[sub_resource type="CapsuleMesh" id=1]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape" id=2]
|
[sub_resource type="CapsuleShape" id=2]
|
||||||
@ -24,7 +23,7 @@ material/0 = null
|
|||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="FrontLeft" type="Spatial" parent="."]
|
[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 )
|
transform = Transform( 0.5, -1.62921e-07, -0.866025, -3.25841e-07, -1, 0, -0.866025, 2.82187e-07, -0.5, 0.6, 0, 1 )
|
||||||
|
|
||||||
[node name="FrontLeftAttachMent" type="MeshInstance" parent="FrontLeft"]
|
[node name="FrontLeftAttachMent" type="MeshInstance" parent="FrontLeft"]
|
||||||
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
||||||
@ -38,10 +37,10 @@ transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
|||||||
shape = SubResource( 4 )
|
shape = SubResource( 4 )
|
||||||
|
|
||||||
[node name="FrontRight" type="Spatial" parent="."]
|
[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 )
|
transform = Transform( 0.5, -1.62921e-07, 0.866025, -3.25841e-07, -1, 0, 0.866025, -2.82187e-07, -0.5, -0.6, 0, 1 )
|
||||||
|
|
||||||
[node name="FrontRightAttachMent" type="MeshInstance" parent="FrontRight"]
|
[node name="FrontRightAttachMent" type="MeshInstance" parent="FrontRight"]
|
||||||
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 5.0822e-21, 0.3, 0, 0, 0 )
|
||||||
mesh = SubResource( 3 )
|
mesh = SubResource( 3 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
|
@ -22,12 +22,13 @@ func _ready() -> void:
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
# We do this here because we want the whole tree to really be done instancing
|
# We do this here because we want the whole tree to really be done instancing
|
||||||
if not setup_done:
|
if not setup_done:
|
||||||
var translation = physics_shape.global_transform.basis * physics_shape.translation
|
var translation = physics_shape.global_transform.origin
|
||||||
|
print(translation)
|
||||||
|
|
||||||
remove_child(physics_shape)
|
remove_child(physics_shape)
|
||||||
base.add_child(physics_shape)
|
base.add_child(physics_shape)
|
||||||
|
|
||||||
physics_shape.translation = translation
|
physics_shape.global_transform.origin = translation
|
||||||
|
|
||||||
setup_done = true
|
setup_done = true
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ class_name PushingBodyPart
|
|||||||
|
|
||||||
onready var touch_area = get_node("TouchArea")
|
onready var touch_area = get_node("TouchArea")
|
||||||
|
|
||||||
|
export(float) var damage = 10.0
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@ -11,7 +13,10 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _on_touch_area_entered(body):
|
func _on_touch_area_entered(body):
|
||||||
if body.name != base.name:
|
if body.name != base.name:
|
||||||
push(body)
|
if body.is_in_group("Terrain"):
|
||||||
|
push(body)
|
||||||
|
elif body.is_in_group("Player"):
|
||||||
|
InGameState.subtract_player_health(body.id, damage)
|
||||||
|
|
||||||
|
|
||||||
func push(body):
|
func push(body):
|
||||||
|
@ -19,7 +19,9 @@ transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 )
|
|||||||
mesh = SubResource( 1 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
[node name="StaticBody" type="StaticBody" parent="MeshInstance"]
|
[node name="StaticBody" type="StaticBody" parent="MeshInstance" groups=[
|
||||||
|
"Terrain",
|
||||||
|
]]
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user