change projectile type to RigidBody3D

This commit is contained in:
Teatov 2025-09-17 01:17:22 +10:00
parent 7ba9a7625a
commit 55f9336c7a
6 changed files with 29 additions and 22 deletions

View File

@ -143,7 +143,6 @@ toggle_pause={
[physics]
common/physics_ticks_per_second=80
common/physics_jitter_fix=0.0
3d/physics_engine="Jolt Physics"
common/physics_interpolation=true

View File

@ -126,7 +126,7 @@ _swing_sounds = SubResource("AudioStreamRandomizer_dt7fs")
[node name="Attacker" type="Area3D" parent="." node_paths=PackedStringArray("_attack_shape_node")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
collision_layer = 32
collision_layer = 0
collision_mask = 32
script = ExtResource("22_dtj7r")
_attack_shape_node = NodePath("AttackShape")

View File

@ -32,15 +32,20 @@ material = ExtResource("7_j3t3l")
size = Vector2(0.4, 0.4)
orientation = 1
[node name="Projectile" type="Area3D" node_paths=PackedStringArray("_model_base", "_model_mesh", "_trail_particles")]
[node name="Projectile" type="RigidBody3D" node_paths=PackedStringArray("_model_base", "_model_mesh", "_trail_particles", "_collision_shape")]
collision_layer = 32
collision_mask = 49
collision_mask = 17
custom_integrator = true
continuous_cd = true
contact_monitor = true
max_contacts_reported = 1
script = ExtResource("1_kv6x5")
_hit_particles_scene = ExtResource("3_a8d2p")
_destroy_particles_scene = ExtResource("4_wq63x")
_model_base = NodePath("Model")
_model_mesh = NodePath("Model/ProjectileMesh")
_trail_particles = NodePath("TrailParticles")
_collision_shape = NodePath("CollisionShape3D")
[node name="Model" parent="." instance=ExtResource("3_oc4rm")]
@ -56,20 +61,18 @@ material_override = ExtResource("5_fdcqu")
mesh = SubResource("QuadMesh_u2n0m")
skeleton = NodePath("../..")
[node name="ShadowDecal" parent="Model" instance=ExtResource("3_2dqcj")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_vc8th")
debug_color = Color(0, 0.6, 0.7, 0.42)
[node name="ShadowDecal" parent="." instance=ExtResource("3_2dqcj")]
[node name="TrailParticles" type="GPUParticles3D" parent="."]
layers = 64
extra_cull_margin = 100.0
amount = 5
lifetime = 0.4
fixed_fps = 60
interpolate = false
fract_delta = false
visibility_aabb = AABB(-0.4, -0.4, -0.4, 0.8, 0.8, 0.8)
process_material = SubResource("ParticleProcessMaterial_fdcqu")
draw_pass_1 = SubResource("QuadMesh_fdcqu")

View File

@ -3,7 +3,7 @@
[ext_resource type="Material" uid="uid://btpy4dp5lb8il" path="res://resources/materials/test_triplanar.tres" id="1_ixaua"]
[ext_resource type="PackedScene" uid="uid://c35losxdelyx1" path="res://scenes/entities/player/batrix.tscn" id="2_lpvoh"]
[ext_resource type="PackedScene" uid="uid://bq8pflbvlf8q7" path="res://scenes/main_camera.tscn" id="3_74lek"]
[ext_resource type="PackedScene" uid="uid://b8pyu60isv7fw" path="res://scenes/entities/player/mint.tscn" id="3_at5dv"]
[ext_resource type="PackedScene" uid="uid://b5fw58o8ifqf7" path="res://scenes/entities/player/mint.tscn" id="3_at5dv"]
[ext_resource type="PackedScene" uid="uid://cksoaevb5sloo" path="res://scenes/entities/enemies/projectile_spawner.tscn" id="4_84n74"]
[ext_resource type="PackedScene" uid="uid://cejn8wfgw14xs" path="res://scenes/entities/projectiles/projectile.tscn" id="5_j5jx5"]
[ext_resource type="PackedScene" uid="uid://xph4078n1fyq" path="res://scenes/debugger.tscn" id="6_lpvoh"]
@ -155,4 +155,5 @@ libraries = {
[node name="Projectile" parent="." instance=ExtResource("5_j5jx5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.1254, 1.08522, -3.37655)
freeze = true
script = null

View File

@ -35,7 +35,7 @@ var _queue_hit_stop: bool
func _ready() -> void:
Debugger.add_event("attacked")
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
area_entered.connect(_on_area_entered)
body_entered.connect(_on_body_entered)
position.y = Projectile.HEIGHT
_set_collision_size(attack_radius)
@ -152,7 +152,7 @@ func _hit_stop(time_scale: float, duration: float) -> void:
Engine.time_scale = 1
func _on_area_entered(node: Node3D) -> void:
func _on_body_entered(node: Node3D) -> void:
if _hit_window_timer <= 0:
return

View File

@ -1,5 +1,5 @@
class_name Projectile
extends Area3D
extends RigidBody3D
const HEIGHT: float = 1
const MAX_STRETCH: float = 0.75
@ -14,6 +14,7 @@ const MAX_STRETCH: float = 0.75
@export var _model_base: Node3D
@export var _model_mesh: MeshInstance3D
@export var _trail_particles: GPUParticles3D
@export var _collision_shape: CollisionShape3D
var _start_position: Vector3
var _velocity: Vector3
@ -38,14 +39,17 @@ func _physics_process(delta: float) -> void:
queue_free()
_life_timer -= delta
global_position += _velocity * delta
look_at(global_position + _velocity, Vector3.UP, true)
linear_velocity = _velocity
if _velocity != Vector3.ZERO:
look_at(global_position + _velocity, Vector3.UP, true)
var speed := _velocity.length()
var speed_squash := clampf(speed / _speed_stretch_factor, 0, MAX_STRETCH)
_model_base.scale = Vector3(1 - speed_squash, 1 - speed_squash, 1 + speed_squash)
_trail_particles.amount = int(speed * _velocity_to_trail_rate)
_trail_particles.emitting = speed > 0
if speed > 0:
_trail_particles.amount = int(speed * _velocity_to_trail_rate)
func init(velocity: Vector3, start_position: Vector3, lifetime: float = 10) -> void:
@ -60,10 +64,10 @@ func hit(velocity: Vector3) -> void:
)
get_tree().get_root().add_child(hit_particles)
hit_particles.init(global_position, velocity)
set_velocity(velocity)
_set_velocity(velocity)
func set_velocity(velocity: Vector3) -> void:
func _set_velocity(velocity: Vector3) -> void:
_velocity = velocity
_life_timer = _lifetime
@ -74,15 +78,15 @@ func _destroy() -> void:
)
get_tree().get_root().add_child(destroy_particles)
destroy_particles.init(global_position)
set_deferred("monitorable", false)
set_deferred("monitoring", false)
set_deferred("freeze", true)
_collision_shape.set_deferred("disabled", true)
_velocity = Vector3.ZERO
linear_velocity = Vector3.ZERO
_model_base.visible = false
await get_tree().create_timer(5).timeout
await get_tree().create_timer(2).timeout
queue_free()
func _on_body_entered(node: Node3D) -> void:
if node is Player:
queue_free()