Better bullet traces and raycast for hitscan
This commit is contained in:
16
scenes/characters/blue/dummy.gd
Normal file
16
scenes/characters/blue/dummy.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
||||
print("head is hit")
|
||||
pass # Replace with function body.
|
@ -1,4 +1,7 @@
|
||||
[gd_scene load_steps=9 format=4 uid="uid://1txob6jskn5s"]
|
||||
[gd_scene load_steps=12 format=4 uid="uid://1txob6jskn5s"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/characters/blue/dummy.gd" id="1_cyeub"]
|
||||
[ext_resource type="Script" path="res://scenes/characters/blue/head_collision.gd" id="1_lianf"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gqjtb"]
|
||||
resource_name = "Alpha_Joints_MAT"
|
||||
@ -255,6 +258,10 @@ blend_shape_mode = 0
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_j3emx"]
|
||||
albedo_color = Color(0, 0, 1, 1)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_k5bjr"]
|
||||
radius = 11.245
|
||||
height = 27.8
|
||||
|
||||
[sub_resource type="Animation" id="Animation_6g1lc"]
|
||||
resource_name = "Run Forward"
|
||||
length = 0.533333
|
||||
@ -861,6 +868,7 @@ _data = {
|
||||
|
||||
[node name="Dummy" type="Node3D"]
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
|
||||
script = ExtResource("1_cyeub")
|
||||
|
||||
[node name="Body" type="Node3D" parent="."]
|
||||
|
||||
@ -1333,7 +1341,25 @@ mesh = SubResource("ArrayMesh_8h4ki")
|
||||
skin = SubResource("Skin_hwx5g")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_j3emx")
|
||||
|
||||
[node name="HitCollisions" type="Node3D" parent="Body/Armature/Skeleton3D"]
|
||||
|
||||
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="Body/Armature/Skeleton3D"]
|
||||
transform = Transform3D(0.978017, -0.176546, -0.110972, 0.15839, 0.282801, 0.94601, -0.135631, -0.942791, 0.304547, -11.8203, 17.7472, -135.936)
|
||||
bone_name = "mixamorig_Head"
|
||||
bone_idx = 5
|
||||
|
||||
[node name="HeadCollision" type="Area3D" parent="Body/Armature/Skeleton3D/BoneAttachment3D" groups=["body"]]
|
||||
transform = Transform3D(9.90229, 1.3945, -6.09554e-08, 0, -4.37114e-07, -10, -1.3945, 9.90229, -4.32843e-07, 0.58762, 7.43451, 1.4646)
|
||||
script = ExtResource("1_lianf")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision"]
|
||||
shape = SubResource("CapsuleShape3D_k5bjr")
|
||||
|
||||
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Body/Armature/Skeleton3D/BoneAttachment3D"]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Body"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_dbxeu")
|
||||
}
|
||||
|
||||
[connection signal="body_part_hit" from="Body/Armature/Skeleton3D/BoneAttachment3D/HeadCollision" to="." method="_on_head_collision_body_part_hit"]
|
||||
|
16
scenes/characters/blue/head_collision.gd
Normal file
16
scenes/characters/blue/head_collision.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends Area3D
|
||||
|
||||
@export var damage: int = 100
|
||||
|
||||
signal body_part_hit(dam)
|
||||
# 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
|
||||
|
||||
func hit():
|
||||
emit_signal("body_part_hit", damage)
|
Reference in New Issue
Block a user