death camera mostly working
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
32
scripts/dead_cam.gd
Normal 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()
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user