From 82d04f89a298ebc390a63eac28d210b7518c2682 Mon Sep 17 00:00:00 2001 From: Squinternator Date: Thu, 11 Apr 2024 12:26:59 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20projectile=20size=20and=20?= =?UTF-8?q?collisions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapons/space_gun/projectile.gd | 7 +++---- weapons/space_gun/projectile.tscn | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/weapons/space_gun/projectile.gd b/weapons/space_gun/projectile.gd index ac28361..96dece8 100644 --- a/weapons/space_gun/projectile.gd +++ b/weapons/space_gun/projectile.gd @@ -1,9 +1,7 @@ extends Node3D -const speed : float = 68.0 +const speed : float = 68.0 # m/s var velocity : Vector3 = Vector3.ZERO - -# @FIXME: with an imaginary box around the map const lifespan : float = 5.0 # in seconds @onready var shape_cast = $ShapeCast3D @@ -30,8 +28,9 @@ func explode(spawn_location): queue_free() func _physics_process(delta): + var previous_position = global_position global_position += velocity * delta - shape_cast.target_position = to_local(global_position - velocity) * delta + shape_cast.target_position = to_local(previous_position) if shape_cast.is_colliding(): var contact_point = shape_cast.collision_result[0].point explode(contact_point) diff --git a/weapons/space_gun/projectile.tscn b/weapons/space_gun/projectile.tscn index 507dc4e..5a115d7 100644 --- a/weapons/space_gun/projectile.tscn +++ b/weapons/space_gun/projectile.tscn @@ -8,14 +8,14 @@ emission_enabled = true emission = Color(0.482353, 0.65098, 1, 1) [sub_resource type="SphereShape3D" id="SphereShape3D_umtte"] -radius = 0.3 +radius = 0.15 [node name="Projectile" type="Node3D"] script = ExtResource("1_4j1dp") [node name="Mesh" type="CSGSphere3D" parent="."] transform = Transform3D(1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0, 0) -radius = 0.3 +radius = 0.15 radial_segments = 24 rings = 8 material = SubResource("StandardMaterial3D_o6j55")