death camera mostly working

This commit is contained in:
derek
2024-08-06 16:57:28 -05:00
parent 5275d80d79
commit f8b0cc2964
11 changed files with 251 additions and 189 deletions

View File

@@ -6,8 +6,10 @@
[sub_resource type="LabelSettings" id="LabelSettings_ic2ps"]
font = ExtResource("1_7a4sr")
font_size = 500
outline_color = Color(1, 1, 1, 0.498039)
[node name="PickupAnnounce" type="Label"]
visible = false
offset_right = 3440.0
offset_bottom = 1440.0
size_flags_horizontal = 3

11
assets/dead_cam.tscn Normal file
View File

@@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://by7qyyhyurlw"]
[ext_resource type="Script" path="res://scripts/dead_cam.gd" id="1_qxtd8"]
[node name="DeadCam" type="Node3D"]
script = ExtResource("1_qxtd8")
[node name="Camera3D" type="Camera3D" parent="."]
[node name="LookRay" type="RayCast3D" parent="."]
target_position = Vector3(0, 0, -1)

View File

@@ -40,7 +40,6 @@ dead_player = ExtResource("2_4hoys")
SENSITIVITY = 0.008
BOB_AMP = 0.085
weapon_holder = NodePath("Head/Camera3D/WeaponHolder")
weapon_sway_amount = 0.5
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
visible = false

View File

@@ -32,12 +32,17 @@ polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Arr
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6yrih"]
albedo_color = Color(0.300579, 0.462784, 0.249767, 1)
[node name="EnemyWork" type="Node3D"]
[node name="EnemyWork" type="Node3D" node_paths=PackedStringArray("player")]
script = ExtResource("1_laua1")
player = NodePath("Player")
MAX_PARTICLES = 75
gun_1 = ExtResource("2_poauc")
gun_2 = ExtResource("3_xdb5c")
[node name="Player" parent="." instance=ExtResource("4_a8lcp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0517487, 5.27336, 0.0530636)
AUDIO = false
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_klp4b")
@@ -45,37 +50,26 @@ environment = SubResource("Environment_klp4b")
transform = Transform3D(-0.78152, -0.330606, 0.52908, 0, 0.848048, 0.529919, -0.62388, 0.414143, -0.662767, 0, 0, 0)
shadow_enabled = true
[node name="Player" parent="." instance=ExtResource("4_a8lcp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00663102, 1.92114, -0.0244913)
AUDIO = false
weapon_sway_amount = 0.07
[node name="EnemyHivemind1" type="Node3D" parent="." groups=["enemy_hivemind"]]
script = ExtResource("5_ngmqi")
[node name="spider" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.87933, 0, 1.40028)
player_path = NodePath("../../Player")
[node name="spider2" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.69998, 9.53674e-07, 3.9282)
player_path = NodePath("../../Player")
[node name="spider3" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.14727, -1.90735e-06, -3.3705)
player_path = NodePath("../../Player")
[node name="spider4" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.485, 0, 1.40028)
player_path = NodePath("../../Player")
[node name="spider5" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.66438, 9.53674e-07, 3.9282)
player_path = NodePath("../../Player")
[node name="spider6" parent="EnemyHivemind1" instance=ExtResource("6_qmuhr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.21709, -1.90735e-06, -3.3705)
player_path = NodePath("../../Player")
[node name="EnemyHivemind2" type="Node3D" parent="." groups=["enemy_hivemind"]]
script = ExtResource("5_ngmqi")

View File

@@ -1169,6 +1169,7 @@ gun_2 = ExtResource("3_umpon")
[node name="Player" parent="." instance=ExtResource("2_f87c2")]
transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, -16.0295, 1.4435, 12.1166)
AUDIO = false
weapon_sway_amount = 0.07
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]

View File

@@ -16,19 +16,20 @@ func _process(delta):
#calculate move position for each child
for i in minions:
#by number of minions determine the amount they should rotate around the player to be evenly distributed
number_minions = minions.size()
#return current array index
var minion_rot_amount = minions.find(i) * deg_to_rad(360 / number_minions)
var player_pos = i.player.global_transform.origin
var minion_pos = player_pos + Vector3(4,0,0)
var nav_pos : Vector3
nav_pos.x = player_pos.x + (minion_pos.x-player_pos.x)*cos(minion_rot_amount) - (minion_pos.z-player_pos.z)*sin(minion_rot_amount)
nav_pos.z = player_pos.z + (minion_pos.x-player_pos.x)*sin(minion_rot_amount) - (minion_pos.z-player_pos.z)*cos(minion_rot_amount)
i.nav_agent.set_target_position(nav_pos)
var next_nav_point = i.nav_agent.get_next_path_position()
i.hive_velocity = (next_nav_point - i.global_transform.origin).normalized() * i.SPEED
if i.player != null:
#by number of minions determine the amount they should rotate around the player to be evenly distributed
number_minions = minions.size()
#return current array index
var minion_rot_amount = minions.find(i) * deg_to_rad(360 / number_minions)
var player_pos = i.player.global_transform.origin
var minion_pos = player_pos + Vector3(4,0,0)
var nav_pos : Vector3
nav_pos.x = player_pos.x + (minion_pos.x-player_pos.x)*cos(minion_rot_amount) - (minion_pos.z-player_pos.z)*sin(minion_rot_amount)
nav_pos.z = player_pos.z + (minion_pos.x-player_pos.x)*sin(minion_rot_amount) - (minion_pos.z-player_pos.z)*cos(minion_rot_amount)
i.nav_agent.set_target_position(nav_pos)
var next_nav_point = i.nav_agent.get_next_path_position()
i.hive_velocity = (next_nav_point - i.global_transform.origin).normalized() * i.SPEED

View File

@@ -17,6 +17,7 @@ var ammo_drop = [[load("res://assets/ammo_pickup.tscn")],["ammo"]]
var stamina_drop = [[load("res://assets/stamina_pickup.tscn")],["stamina"]]
var health_drop = [[load("res://assets/health_pickup.tscn")],["health"]]
var money_drop = [[load("res://assets/money_pickup.tscn")],["money"]]
var dead_player = preload("res://assets/dead_cam.tscn")
const CLEARED_ANNOUNCE = preload("res://assets/cleared_announce.tscn")
const DEAD_ANNOUNCE = preload("res://assets/dead_announce.tscn")
@@ -29,6 +30,7 @@ var current_gun_index
var particle_number = 0
var enemy_hiveminds = []
var remaining_enemies
var last_hit : Node
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -49,22 +51,23 @@ func _ready():
if money_drop_enabled == true:
pickups.append(money_drop)
#Set up starting guns and ammo
held_guns = [gun_1]
var instance_gun = held_guns[0].instantiate()
ammo_current[0] = instance_gun.max_ammo
ammo_reserve[0] = instance_gun.max_ammo * instance_gun.start_mags
if gun_2 != null:
held_guns.append(gun_2)
var instance_gun_2 = held_guns[1].instantiate()
ammo_current.append(instance_gun_2.max_ammo)
ammo_reserve.append(instance_gun_2.max_ammo * instance_gun_2.start_mags)
if player:
#Set up starting guns and ammo
held_guns = [gun_1]
var instance_gun = held_guns[0].instantiate()
ammo_current[0] = instance_gun.max_ammo
ammo_reserve[0] = instance_gun.max_ammo * instance_gun.start_mags
if gun_2 != null:
held_guns.append(gun_2)
var instance_gun_2 = held_guns[1].instantiate()
ammo_current.append(instance_gun_2.max_ammo)
ammo_reserve.append(instance_gun_2.max_ammo * instance_gun_2.start_mags)
# Spawn first gun
current_gun_index = 0
gun_spawn(0)
# Spawn first gun
current_gun_index = 0
gun_spawn(0)
#find enemy hiveminds
for node in get_tree().get_nodes_in_group("enemy_hivemind"):
enemy_hiveminds.append(node)
@@ -74,8 +77,11 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func gun_spawn(index):
#loop around if scrolling past available guns
if index > held_guns.size() - 1:
index = 0
@@ -111,21 +117,24 @@ func cleared():
func die():
Engine.time_scale = .05
AudioServer.set_bus_effect_enabled(0,0,true)
var deadmsg = DEAD_ANNOUNCE.instantiate()
get_parent().add_child(deadmsg)
await get_tree().create_timer(.3).timeout
get_tree().reload_current_scene()
#var instance_dead = dead_player.instantiate()
#instance_dead.position = head.global_position
#instance_dead.transform.basis = head.global_transform.basis
#get_tree().get_root().add_child(instance_dead)
var instance_dead = dead_player.instantiate()
instance_dead.global_position = player.global_position
instance_dead.transform.basis = player.global_transform.basis
#instance_dead.camera.rotation = player.camera.rotation
instance_dead.target = last_hit
get_tree().get_root().add_child(instance_dead)
instance_dead.camera.current = true
player.dead = true
player.gun.visible = false
player.crosshair.visible = false
func pickup_spawn():
var item_type = pickups.pick_random()
var item_spawn = item_type[0][0].instantiate()
var item_name = item_type[1][0]
print(item_name)
item_spawn.rand_amt = randi_range(25,100)
return item_spawn

View File

@@ -7,6 +7,7 @@ var bullet_damage
var bullet_force_mod = 1.0
var distance_from_player
var player
var fired_by
@onready var mesh = $gunbullet1
@onready var ray = $RayCast3D
@@ -16,8 +17,8 @@ var player
@onready var gunbullet1 = $gunbullet1/Cylinder
@onready var hit_indicator = $Audio/HitIndicator
@export var bullethole : Resource
@onready var level_control = get_tree().current_scene
var level_control
var rng = RandomNumberGenerator.new()
var av_x
var av_y
@@ -32,18 +33,22 @@ func _ready():
rotation += Vector3(av_x,av_y,av_z)
timer.start()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
position += transform.basis * Vector3(0, 0, -bullet_speed) * delta
rotation.x = clamp(rotation.x - delta * bullet_drop,deg_to_rad(-90),deg_to_rad(90))
if ray.is_colliding() and ray.get_collider != null:
if ray.is_colliding() and ray.get_collider() != null:
if ray.get_collider().is_in_group("player"):
var player = ray.get_collider()
player.level_control.health -= bullet_damage
player.hurt_audio.play()
queue_free()
if player.level_control.health <= bullet_damage:
player.level_control.last_hit = fired_by
player.hurt_audio.play()
else:
queue_free()
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):

32
scripts/dead_cam.gd Normal file
View File

@@ -0,0 +1,32 @@
extends Node3D
@export var MOVE_SPEED = 15
@export var CAMERA_LOOK_SPEED = 20
@onready var look_ray = $LookRay
@onready var camera = $Camera3D
var target : Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
# Move towards and look at target
#calculate move direction
var target_pos_adjusted = Vector3(target.position.x -2,target.position.y + 4,target.position.z -2)
position = lerp(position,target_pos_adjusted,delta * MOVE_SPEED)
look_ray.look_at(Vector3(target.global_position), Vector3.UP)
camera.rotation = lerp(camera.rotation,look_ray.rotation,delta * CAMERA_LOOK_SPEED)
if Input.is_action_just_pressed("escape"):
get_tree().reload_current_scene()
queue_free()

View File

@@ -56,6 +56,7 @@ var bullet_destination
var gun_fire_pitch_starting
var current_weapon_index
var recoiling = false
var dead = false
# Slow Down Variables
const SLOWSPEED = .2
@@ -98,136 +99,139 @@ func _unhandled_input(event):
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
else:
double_jump = true
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor() and !is_climbing:
velocity.y += JUMP_VELOCITY
elif Input.is_action_just_pressed("jump") and double_jump == true and !is_climbing:
velocity.y += JUMP_VELOCITY
double_jump = false
if !dead:
# Handle Sprint
if Input.is_action_pressed("sprint") and is_on_floor():
speed = SPRINT_SPEED
else:
speed = WALK_SPEED
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor() and !is_climbing:
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
else:
double_jump = true
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor() and !is_climbing:
velocity.y += JUMP_VELOCITY
elif Input.is_action_just_pressed("jump") and double_jump == true and !is_climbing:
velocity.y += JUMP_VELOCITY
double_jump = false
# Handle Sprint
if Input.is_action_pressed("sprint") and is_on_floor():
speed = SPRINT_SPEED
else:
speed = WALK_SPEED
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor() and !is_climbing:
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
elif is_climbing:
gravity = 0.0
if direction:
velocity.y = -direction.z * speed * .75
velocity.x = direction.x * speed * .3
else:
velocity.y = lerp(velocity.y, -direction.z * speed, delta * 6.5)
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
elif is_climbing:
gravity = 0.0
if direction:
velocity.y = -direction.z * speed * .75
velocity.x = direction.x * speed * .3
else:
velocity.y = lerp(velocity.y, -direction.z * speed, delta * 6.5)
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
# Head bob
t_bob += delta * velocity.length() * float(is_on_floor())
camera.transform.origin = _headbob(t_bob)
# FOV
var velocity_clamped = clamp(velocity.length(), 0.5, SPRINT_SPEED * 2)
var target_fov = BASE_FOV + FOV_CHANGE * velocity_clamped
camera.fov = lerp(camera.fov, target_fov, delta * 8)
# Land sound
# Game Speed
if Input.is_action_pressed("slow_down") and remaining_stamina >0:
Engine.time_scale = lerp(0, 1, SLOWSPEED)
gun.random_spread_amt = 0
AudioServer.set_bus_effect_enabled(0,0,true)
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
if sensitivity_shift == true:
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
if remaining_stamina >0:
remaining_stamina -= 1000 * delta
else:
Engine.time_scale = 1
gun.random_spread_amt = gun.random_spread_start
AudioServer.set_bus_effect_enabled(0,0,false)
if sensitivity_shift == true:
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
SENSITIVITY = start_sensitivity
if remaining_stamina < MAX_STAMINA:
remaining_stamina += STAMINA_DRAIN * delta
elif remaining_stamina > MAX_STAMINA * 1.01:
remaining_stamina -= (STAMINA_DRAIN)/2 * delta
# Reloading
if Input.is_action_just_pressed("reload"):
gun.reload(delta)
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
gun.anim_player.play("inspect")
# Shooting & fire modes
if Input.is_action_pressed("shoot"):
gun.shoot(delta)
if Input.is_action_just_released("shoot"):
gun.cycle_count = gun.cycle_count_start
# Gun folding out of the way
if gun_ray.is_colliding() and !gun_ray.get_collider().is_in_group("player"):
#check distance to wall later ?
gun.rotation = lerp(gun.rotation, Vector3(1, -1, -.25), delta * 10)
gun.position = lerp(gun.position, Vector3(gun.start_position.x+.25,gun.start_position.y +.2,gun.start_position.z +.6),(delta*10))
gun_folded = true
elif !gun_ray.is_colliding():
gun.rotation = lerp(gun.rotation, gun.start_rotation,delta*7)
gun.position = lerp(gun.position, gun.start_position,delta*7)
gun_folded = false
#Weapon Swap Up
if Input.is_action_just_pressed("scroll_up") and !gun.anim_player.is_playing():
if level_control.held_guns.size() > 1:
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index + 1)
#Weapon Swap Down
if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing():
if level_control.held_guns.size() > 1:
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index - 1)
#interact button
if Input.is_action_just_pressed("interact"):
if interact_ray.is_colliding(): # and !interact_ray.get_collider().is_in_group("interact"):
var body = interact_ray.get_collider()
body.get_parent().interact()
# Head bob
t_bob += delta * velocity.length() * float(is_on_floor())
camera.transform.origin = _headbob(t_bob)
# FOV
var velocity_clamped = clamp(velocity.length(), 0.5, SPRINT_SPEED * 2)
var target_fov = BASE_FOV + FOV_CHANGE * velocity_clamped
camera.fov = lerp(camera.fov, target_fov, delta * 8)
# Land sound
# Game Speed
if Input.is_action_pressed("slow_down") and remaining_stamina >0:
Engine.time_scale = lerp(0, 1, SLOWSPEED)
gun.random_spread_amt = 0
AudioServer.set_bus_effect_enabled(0,0,true)
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
if sensitivity_shift == true:
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100)
if remaining_stamina >0:
remaining_stamina -= 1000 * delta
else:
Engine.time_scale = 1
gun.random_spread_amt = gun.random_spread_start
AudioServer.set_bus_effect_enabled(0,0,false)
if sensitivity_shift == true:
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
SENSITIVITY = start_sensitivity
if remaining_stamina < MAX_STAMINA:
remaining_stamina += STAMINA_DRAIN * delta
elif remaining_stamina > MAX_STAMINA * 1.01:
remaining_stamina -= (STAMINA_DRAIN)/2 * delta
# Reloading
if Input.is_action_just_pressed("reload"):
gun.reload(delta)
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
gun.anim_player.play("inspect")
# Shooting & fire modes
if Input.is_action_pressed("shoot"):
gun.shoot(delta)
#quit game and eventually go to menu
if Input.is_action_just_pressed("escape"):
get_tree().quit()
if level_control.health <= 0:
level_control.die()
move_and_slide()
weapon_tilt(input_dir.x, delta)
weapon_sway(delta)
weapon_bob(velocity.length(), delta)
if Input.is_action_just_released("shoot"):
gun.cycle_count = gun.cycle_count_start
# Gun folding out of the way
if gun_ray.is_colliding() and !gun_ray.get_collider().is_in_group("player"):
#check distance to wall later ?
gun.rotation = lerp(gun.rotation, Vector3(1, -1, -.25), delta * 10)
gun.position = lerp(gun.position, Vector3(gun.start_position.x+.25,gun.start_position.y +.2,gun.start_position.z +.6),(delta*10))
gun_folded = true
elif !gun_ray.is_colliding():
gun.rotation = lerp(gun.rotation, gun.start_rotation,delta*7)
gun.position = lerp(gun.position, gun.start_position,delta*7)
gun_folded = false
#Weapon Swap Up
if Input.is_action_just_pressed("scroll_up") and !gun.anim_player.is_playing():
if level_control.held_guns.size() > 1:
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index + 1)
#Weapon Swap Down
if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing():
if level_control.held_guns.size() > 1:
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index - 1)
#interact button
if Input.is_action_just_pressed("interact"):
if interact_ray.is_colliding(): # and !interact_ray.get_collider().is_in_group("interact"):
var body = interact_ray.get_collider()
body.get_parent().interact()
#quit game and eventually go to menu
if Input.is_action_just_pressed("escape"):
get_tree().quit()
if level_control.health <= 0:
level_control.die()
move_and_slide()
weapon_tilt(input_dir.x, delta)
weapon_sway(delta)
weapon_bob(velocity.length(), delta)
func _headbob(time) -> Vector3:
var pos = Vector3.ZERO

View File

@@ -1,6 +1,6 @@
extends CharacterBody3D
var player = null
var player
@export var health = 3
@export var number_of_drops = 3
@@ -19,7 +19,7 @@ const MAX_AV = 10
@onready var level_control = get_tree().current_scene
@onready var nav_agent = $NavigationAgent3D
@onready var target = $body/target
#@onready var target = $body/target
@onready var movement_shape = $MovementShape
@onready var barrel_1 = $TurretLook/Turret/Barrel1
@onready var barrel_2 = $TurretLook/Turret/Barrel2
@@ -57,7 +57,7 @@ var knocked = false
var stunned = false
func _ready():
player = get_node(player_path)
player = level_control.player
turret_material.emission_enabled = false
#randomly start the postfire timer so enemy turrets aren't synced
@@ -69,13 +69,15 @@ func _process(delta):
# Navigation
if !knocked:
velocity = hive_velocity
if hive_velocity:
velocity = hive_velocity
if !stunned:
spider_look_next.look_at(Vector3(player.global_position.x, 0, player.global_position.z), Vector3.UP)
body.rotation.y = lerp(body.rotation.y, spider_look_next.rotation.y, delta * 1)
turret_look_next.look_at(player.global_position,Vector3.UP)
turret_look.rotation = lerp(turret_look.rotation,turret_look_next.rotation,delta * turret_look_speed)
if player != null:
spider_look_next.look_at(Vector3(player.global_position.x, 0, player.global_position.z), Vector3.UP)
body.rotation.y = lerp(body.rotation.y, spider_look_next.rotation.y, delta * 1)
turret_look_next.look_at(player.global_position,Vector3.UP)
turret_look.rotation = lerp(turret_look.rotation,turret_look_next.rotation,delta * turret_look_speed)
else:
body.rotation.y = lerp(body.rotation.y, body.rotation.y + 10, delta * .1)
turret_look.rotation.y = lerp(turret_look.rotation.y,turret_look.rotation.y - 10,delta * .5)
@@ -130,6 +132,7 @@ func _on_prefire_timer_timeout():
instance_bullet.bullet_drop = bullet_drop
instance_bullet.random_spread_amt = random_spread_amt
instance_bullet.bullet_damage = bullet_damage
instance_bullet.fired_by = self
get_tree().get_root().add_child(instance_bullet)
#barrel 2 fire
@@ -140,6 +143,7 @@ func _on_prefire_timer_timeout():
instance_bullet2.bullet_drop = bullet_drop
instance_bullet2.random_spread_amt = random_spread_amt
instance_bullet2.bullet_damage = bullet_damage
instance_bullet2.fired_by = self
get_tree().get_root().add_child(instance_bullet2)
turret_material.emission_enabled = false