Tweaks to the rocket launcher

This commit is contained in:
unfa 2022-01-01 02:55:27 +01:00
parent 5dbc840ef4
commit 02d0bee09c
4 changed files with 16 additions and 13 deletions

View file

@ -2,11 +2,10 @@ extends Node3D
@export var hit_effect_scene : PackedScene
@export var speed : float
@export var damage : int
var damage : int
var source_position : Vector3
var player
var noise = OpenSimplexNoise.new()
var time := 0.0
#var active := true
@ -29,11 +28,6 @@ func _ready():
halo.mesh.surface_set_material(0, halo_material)
#$OmniLight3D/Smoke.emitting = true
noise.octaves = 2
noise.persistence = 0.8
noise.period = 16
noise.seed = randi()
func _physics_process(delta):
#constant_linear_velocity = Vector3(1, 0, 0)
translate_object_local(Vector3.FORWARD * speed * delta)
@ -50,7 +44,6 @@ func _process(delta):
$OmniLight3D.light_energy = 3 + flicker /2
halo.mesh.size = Vector2.ONE * 1.5 + Vector2(flicker, flicker) / 16
var space_state = get_world_3d().direct_space_state
var physics_ray_query_parameters_3d = PhysicsRayQueryParameters3D.new()
physics_ray_query_parameters_3d.from = halo.global_transform.origin
@ -71,10 +64,9 @@ func _process(delta):
ray_previously = false
if halo.visible:
var fade = 1 - clamp((physics_ray_query_parameters_3d.from.distance_squared_to(physics_ray_query_parameters_3d.to) / 1000 ), 0, 1)
var fade = 1 - clamp(pow(physics_ray_query_parameters_3d.from.distance_to(physics_ray_query_parameters_3d.to), 1.5) / 800, 0, 1)
#print(fade)
halo.mesh.surface_get_material(0)["albedo_color"] = halo_color * fade
func give_damage(target: Node, hit_position: Vector3, hit_normal: Vector3, damage: int, source_position: Vector3, type: Globals.DamageType, push: float):
if target.has_method(&'take_damage'): # we've hit a player or something else - the ywill handle everything like effects etc.
@ -108,6 +100,7 @@ func _on_Area3D_body_entered(body):
$Area3D.queue_free()
$Rocket.queue_free()
$Timer2.start()
$AmbientSound.stop()
func _on_Timer_timeout():
queue_free()

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=17 format=3 uid="uid://bt0lppumya6fv"]
[gd_scene load_steps=18 format=3 uid="uid://bt0lppumya6fv"]
[ext_resource type="Script" path="res://Assets/Weapons/Projectile.gd" id="1_3ywpo"]
[ext_resource type="PackedScene" uid="uid://wvxhewre31mo" path="res://Assets/Effects/ImpactExplosion.tscn" id="2_1tben"]
[ext_resource type="PackedScene" uid="uid://db4ibhxmrgqny" path="res://Assets/Weapons/RocketLauncher/Rocket.gltf" id="3_wqrr6"]
[ext_resource type="Texture2D" uid="uid://pnh872qjk0oy" path="res://Assets/Effects/Flame.png" id="4_aitcu"]
[ext_resource type="AudioStream" uid="uid://bmjh522fpxeee" path="res://Assets/SFX/Player_Jetpack.wav" id="5_v5pxv"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_qjk68"]
radius = 0.0853144
@ -97,7 +98,6 @@ material = SubResource( "StandardMaterial3D_yhx2h" )
script = ExtResource( "1_3ywpo" )
hit_effect_scene = ExtResource( "2_1tben" )
speed = 35.0
damage = 75
halo_color = Color(1, 0.529412, 0.270588, 1)
[node name="Rocket" parent="." instance=ExtResource( "3_wqrr6" )]
@ -161,6 +161,15 @@ autostart = true
wait_time = 2.0
one_shot = true
[node name="AmbientSound" type="AudioStreamPlayer3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00287104, 0.0138369, -0.0329528)
stream = ExtResource( "5_v5pxv" )
unit_db = -8.0
unit_size = 4.0
max_db = 0.0
pitch_scale = 1.95
autoplay = true
[connection signal="body_entered" from="Area3D" to="." method="_on_Area3D_body_entered"]
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
[connection signal="timeout" from="Timer2" to="." method="_on_Timer2_timeout"]

View file

@ -10,7 +10,7 @@
[node name="Weapon" instance=ExtResource( "1_x28sf" )]
weapon_type = 1
projectile_or_tracer_scene = ExtResource( "2_xwyny" )
weapon_damage = 125
weapon_damage = 50
[node name="RocketLauncher" parent="." index="0" instance=ExtResource( "2_a04bi" )]

View file

@ -120,6 +120,7 @@ var spread = spread_min
projectile_instance.global_transform = muzzle.global_transform.looking_at(to)
projectile_instance.source_position = player.global_transform.origin
projectile_instance.player = player
projectile_instance.damage = weapon_damage
#projectile_instance.get_node("RayCast3D").add_exception(player)
#projectile_instance.rotate_x(PI/2)
get_tree().root.add_child(projectile_instance)