Does anyone know how to make the Cameras switch in a delay of 0.75 seconds between each camera when the Player wins?
I've tried a lot of things from timers to other stuff i can't remember and i just can't get it to work
The code:
extends Node3D
const BOSS_START_SCORE = 1300
var BOSS_SCORE_INCREASE = 20
var BOSS_SCORE_DECREASE = 9.5
var PLAYER_START_SCORE = 1300
var PLAYER_SCORE_INCREASE = 50
var PLAYER_SCORE_DECREASE = 250
var BUTTON_MASH_DELAY = 0
var boss_score = BOSS_START_SCORE
var player_score = PLAYER_START_SCORE
var last_button_mash_time = 0
var win = false
var pause = false
#Cameras i want to switch to upon the player winning
@onready var startcam = $CAMERA3D
@onready var wincam1 = $CAMERA3D2
@onready var wincam2 = $CAMERA3D3
@onready var wincam3 = $CAMERA3D4
# The camera that follows the player
@onready var camera: Camera3D = $Camera3D
# The boss
@onready var boss: Node3D = $Boss
# The player
@onready var player: Node3D = $Player
const WINNING_ANGLE = 35
func _ready():
pass
func _process(delta):
if Input.is_action_just_pressed("button1") or Input.is_action_just_pressed("button2") or Input.is_action_just_pressed("button3"):
$Flash.set_volume_db(15)
$Flash.play()
if pause:
BOSS_SCORE_DECREASE = 0
PLAYER_SCORE_DECREASE = 0
PLAYER_SCORE_INCREASE = 0
BOSS_SCORE_INCREASE = 0
if not win:
boss_score += BOSS_SCORE_INCREASE * delta
if Input.is_action_just_pressed("button1") and Input.is_action_just_pressed("button2"):
player_score += PLAYER_SCORE_INCREASE
else:
player_score -= PLAYER_SCORE_DECREASE * delta
if Input.is_action_just_pressed("button1") and !Input.is_action_just_pressed("button2"):
if last_button_mash_time == 0 or (Time.get_ticks_msec() - last_button_mash_time) > BUTTON_MASH_DELAY * 1000:
boss_score -= BOSS_SCORE_DECREASE/2.1
last_button_mash_time = Time.get_ticks_msec()
player_score += PLAYER_SCORE_INCREASE/2.1
if !Input.is_action_just_pressed("button1") and Input.is_action_just_pressed("button2"):
if last_button_mash_time == 0 or (Time.get_ticks_msec() - last_button_mash_time) > BUTTON_MASH_DELAY * 1000:
boss_score -= BOSS_SCORE_DECREASE/2.1
last_button_mash_time = Time.get_ticks_msec()
player_score += PLAYER_SCORE_INCREASE/2.1
if Input.is_action_just_pressed("button3"):
if last_button_mash_time == 0 or (Time.get_ticks_msec() - last_button_mash_time) > BUTTON_MASH_DELAY * 1000:
boss_score -= BOSS_SCORE_DECREASE/4
last_button_mash_time = Time.get_ticks_msec()
player_score += PLAYER_SCORE_INCREASE/4
if Input.is_action_just_pressed("pause"):
$Pause.play()
if win:
PLAYER_SCORE_DECREASE = 0
PLAYER_SCORE_INCREASE = 0
BOSS_SCORE_DECREASE = 0
BOSS_SCORE_INCREASE = 0
if player_score <= 0:
player_score = 0
# Calculate the camera rotation based on the scores
var rotation_y = lerp(WINNING_ANGLE, -WINNING_ANGLE, max(0, player_score / (player_score + boss_score)))
camera.rotation_degrees.y = rotation_y
if boss_score <= 0:
boss_score = -1
win = true
print("WIN")
$RigidBody3D/CollisionShape3D/Boss/AnimationTree.set("parameters/conditions/WIN", true)
$RigidBody3D/CollisionShape3D/Boss/AnimationTree.set("parameters/conditions/START", false)
$RigidBody3D/CollisionShape3D/Boss/AnimationTree.set("parameters/conditions/START", false)