mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-16 08:55:33 +00:00
Merge branch 'feat/projectile-smoothing' into 'develop'
✨ Projectile smoothing See merge request open-fpsz/open-fpsz!73
This commit is contained in:
commit
0251dc0a5e
2 changed files with 42 additions and 24 deletions
|
|
@ -18,9 +18,11 @@ class_name Projectile extends Node3D
|
||||||
@export var EXPLOSION : PackedScene
|
@export var EXPLOSION : PackedScene
|
||||||
@export var speed : float = 78.4 # m/s
|
@export var speed : float = 78.4 # m/s
|
||||||
@export var lifespan : float = 5.0 # in seconds
|
@export var lifespan : float = 5.0 # in seconds
|
||||||
|
@export var _time_to_trail_enable : float = 0.05 # in seconds
|
||||||
|
|
||||||
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
@onready var shape_cast : ShapeCast3D = $ShapeCast3D
|
||||||
@onready var game : Node3D = get_tree().get_current_scene()
|
@onready var game : Node3D = get_tree().get_current_scene()
|
||||||
|
@onready var projectile_trail : Trail3D = $Smoothing/ProjectileTrail
|
||||||
|
|
||||||
var velocity : Vector3 = Vector3.ZERO
|
var velocity : Vector3 = Vector3.ZERO
|
||||||
var shooter : Player
|
var shooter : Player
|
||||||
|
|
@ -32,6 +34,13 @@ func _ready() -> void:
|
||||||
lifespan_timer.autostart = true
|
lifespan_timer.autostart = true
|
||||||
lifespan_timer.timeout.connect(self_destruct)
|
lifespan_timer.timeout.connect(self_destruct)
|
||||||
add_child(lifespan_timer)
|
add_child(lifespan_timer)
|
||||||
|
projectile_trail._trail_enabled = false
|
||||||
|
var trail_enable_timer : Timer = Timer.new()
|
||||||
|
trail_enable_timer.wait_time = _time_to_trail_enable
|
||||||
|
trail_enable_timer.one_shot = true
|
||||||
|
trail_enable_timer.autostart = true
|
||||||
|
trail_enable_timer.timeout.connect(_enable_trail)
|
||||||
|
add_child(trail_enable_timer)
|
||||||
|
|
||||||
func self_destruct() -> void:
|
func self_destruct() -> void:
|
||||||
explode(position)
|
explode(position)
|
||||||
|
|
@ -50,3 +59,6 @@ func _physics_process(delta : float) -> void:
|
||||||
if shape_cast.is_colliding():
|
if shape_cast.is_colliding():
|
||||||
var contact_point : Vector3 = shape_cast.collision_result[0].point
|
var contact_point : Vector3 = shape_cast.collision_result[0].point
|
||||||
explode(contact_point)
|
explode(contact_point)
|
||||||
|
|
||||||
|
func _enable_trail() -> void:
|
||||||
|
projectile_trail._trail_enabled = true
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://dn1tcakam5egs"]
|
[gd_scene load_steps=8 format=3 uid="uid://dn1tcakam5egs"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile.gd" id="1_4j1dp"]
|
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile.gd" id="1_4j1dp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://8atq41j7wd55" path="res://entities/weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
|
[ext_resource type="PackedScene" uid="uid://8atq41j7wd55" path="res://entities/weapons/space_gun/projectile_explosion.tscn" id="2_llml6"]
|
||||||
|
[ext_resource type="Script" path="res://addons/smoothing/smoothing.gd" id="3_dmi64"]
|
||||||
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_trail.gd" id="3_ygqbh"]
|
[ext_resource type="Script" path="res://entities/weapons/space_gun/projectile_trail.gd" id="3_ygqbh"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_umtte"]
|
||||||
|
radius = 0.15
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_o6j55"]
|
||||||
|
albedo_color = Color(0, 0.498039, 0.854902, 1)
|
||||||
|
emission_enabled = true
|
||||||
|
emission = Color(0.482353, 0.65098, 1, 1)
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4a265"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4a265"]
|
||||||
transparency = 1
|
transparency = 1
|
||||||
blend_mode = 1
|
blend_mode = 1
|
||||||
|
|
@ -11,33 +20,10 @@ cull_mode = 2
|
||||||
shading_mode = 0
|
shading_mode = 0
|
||||||
vertex_color_use_as_albedo = true
|
vertex_color_use_as_albedo = true
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_o6j55"]
|
|
||||||
albedo_color = Color(0, 0.498039, 0.854902, 1)
|
|
||||||
emission_enabled = true
|
|
||||||
emission = Color(0.482353, 0.65098, 1, 1)
|
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_umtte"]
|
|
||||||
radius = 0.15
|
|
||||||
|
|
||||||
[node name="Projectile" type="Node3D"]
|
[node name="Projectile" type="Node3D"]
|
||||||
script = ExtResource("1_4j1dp")
|
script = ExtResource("1_4j1dp")
|
||||||
EXPLOSION = ExtResource("2_llml6")
|
EXPLOSION = ExtResource("2_llml6")
|
||||||
|
|
||||||
[node name="ProjectileTrail" type="MeshInstance3D" parent="."]
|
|
||||||
material_override = SubResource("StandardMaterial3D_4a265")
|
|
||||||
script = ExtResource("3_ygqbh")
|
|
||||||
_start_width = 0.15
|
|
||||||
_lifespan = 0.25
|
|
||||||
_start_color = Color(0, 0.498039, 0.854902, 1)
|
|
||||||
_end_color = Color(1, 1, 1, 0)
|
|
||||||
|
|
||||||
[node name="Mesh" type="CSGSphere3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0, 0)
|
|
||||||
radius = 0.15
|
|
||||||
radial_segments = 24
|
|
||||||
rings = 8
|
|
||||||
material = SubResource("StandardMaterial3D_o6j55")
|
|
||||||
|
|
||||||
[node name="ShapeCast3D" type="ShapeCast3D" parent="."]
|
[node name="ShapeCast3D" type="ShapeCast3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0, 0)
|
||||||
shape = SubResource("SphereShape3D_umtte")
|
shape = SubResource("SphereShape3D_umtte")
|
||||||
|
|
@ -46,3 +32,23 @@ margin = 0.1
|
||||||
max_results = 1
|
max_results = 1
|
||||||
collision_mask = 2147483649
|
collision_mask = 2147483649
|
||||||
debug_shape_custom_color = Color(1, 0, 0, 1)
|
debug_shape_custom_color = Color(1, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="Smoothing" type="Node3D" parent="."]
|
||||||
|
script = ExtResource("3_dmi64")
|
||||||
|
target = NodePath("..")
|
||||||
|
|
||||||
|
[node name="Mesh" type="CSGSphere3D" parent="Smoothing"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0, 0)
|
||||||
|
radius = 0.15
|
||||||
|
radial_segments = 24
|
||||||
|
rings = 8
|
||||||
|
material = SubResource("StandardMaterial3D_o6j55")
|
||||||
|
|
||||||
|
[node name="ProjectileTrail" type="MeshInstance3D" parent="Smoothing"]
|
||||||
|
material_override = SubResource("StandardMaterial3D_4a265")
|
||||||
|
skeleton = NodePath("../..")
|
||||||
|
script = ExtResource("3_ygqbh")
|
||||||
|
_start_width = 0.15
|
||||||
|
_lifespan = 0.25
|
||||||
|
_start_color = Color(0, 0.498039, 0.854902, 1)
|
||||||
|
_end_color = Color(1, 1, 1, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue