fixed shotgun pellets

This commit is contained in:
derek
2025-04-17 14:04:48 -05:00
parent bcc9d788a9
commit 58944de345
5 changed files with 17 additions and 19 deletions

View File

@@ -298,8 +298,8 @@ tracks/3/keys = {
[sub_resource type="Animation" id="Animation_bsc1a"]
resource_name = "shoot"
length = 0.1
step = 0.01
length = 0.05
step = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@@ -307,7 +307,7 @@ tracks/0/path = NodePath("gun:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.03, 0.1),
"times": PackedFloat32Array(0, 0.016, 0.05),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector3(0, -0.000397999, 0), Vector3(0, 0.0908759, 0.176503), Vector3(0, -0.000397999, 0)]
@@ -319,7 +319,7 @@ tracks/1/path = NodePath("gun:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.03, 0.1),
"times": PackedFloat32Array(0, 0.016, 0.05),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector3(0, -1.5708, 0), Vector3(-1.34655e-08, -1.5708, -0.313147), Vector3(0, -1.5708, 0)]
@@ -331,7 +331,7 @@ tracks/2/path = NodePath("gun/slide:position")
tracks/2/interp = 2
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.04, 0.1),
"times": PackedFloat32Array(0, 0.026, 0.05),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(0.4, 0, 0), Vector3(0, 0, 0)]

View File

@@ -27,7 +27,7 @@ _data = {
&"pellet_glow": SubResource("Animation_s2rms")
}
[node name="ShotgunPellet" type="RigidBody3D" groups=["pellet", "spawned"]]
[node name="ShotgunPellet" type="RigidBody3D" node_paths=PackedStringArray("collision_shape", "mesh") groups=["pellet", "spawned"]]
collision_layer = 160
collision_mask = 233
mass = 0.01
@@ -36,7 +36,8 @@ continuous_cd = true
contact_monitor = true
max_contacts_reported = 1
script = ExtResource("1_1v1ju")
max_bounces = 20
collision_shape = NodePath("CollisionShape3D")
mesh = NodePath("MeshInstance3D")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_5okb1")

Binary file not shown.

Binary file not shown.

View File

@@ -1,14 +1,15 @@
extends Projectile
@export var max_bounces : int = 10
@export var collision_shape: CollisionShape3D
@export var mesh: MeshInstance3D
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
@onready var mesh: MeshInstance3D = $MeshInstance3D
@onready var material = mesh.get_surface_override_material(0)
var bounces = 0
var start_time
var end_time
var despawning = false
const EMISSION_MAX : float = 200
const EMISSION_LIFETIME : float = 1.75 #in seconds
@@ -24,19 +25,15 @@ func _process(delta: float) -> void:
var current_time = (Time.get_ticks_msec())/end_time
material.emission_energy_multiplier = clamp(lerp(EMISSION_MAX,0.0,current_time),0,EMISSION_MAX)
func _on_body_entered(body: Node) -> void:
bounces += 1
if bounces >= max_bounces:
despawn()
if linear_velocity.length() >= VELOCITY_REQUIRED_TO_HIT:
damage(body)
if despawning:
linear_velocity.y -= .1 * delta
func despawn():
collision_shape.disabled = true
await get_tree().create_timer(1).timeout
self.queue_free()
gravity_scale = 0
despawning = true
await get_tree().create_timer(2).timeout
queue_free()
func _on_timer_timeout() -> void: