How to make the portal appear only when the boss is dead ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Scavex

Hello guys I wanted to know that how can I actually make a portal appear or function only when the boss dies. For example in my case I have a boss who the player can skip and go to portal to reach the next level and that’s not what I intend. I want the player to defeat he boss and only then he can use the portal.
Here’s the Portal Script :

extends Area2D

export(String,FILE,"*.tscn")var TargetScene

func _ready() -> void:
	pass 


func _on_ChangeStage_body_entered(body: Node) -> void:
	if "Player" in body.name:
		get_tree().change_scene(TargetScene)

Here is the Boss Script :

extends KinematicBody2D
const GRAVITY =10
export(int) var SPEED =20
const FLOOR=Vector2(0,1)
var velocity=Vector2()
export(String,FILE,"*.tscn")var TargetScene

var direction=1

var is_dead=false
export(int) var hp=30


func _ready() -> void:
	pass # Replace with function body.

func dead():
	hp-=1
	if hp<=0:
		is_dead=true
		velocity=Vector2(0,0)
		$AnimatedSprite.play("Dead")
		$CollisionShape2D.disabled=true
		
		$Timer.start()


func _physics_process(delta):
	if is_dead==false:
		velocity.x=SPEED*direction*3
		if hp<=15:
			velocity.x=SPEED*direction*6
			
		if direction == 1:
			$AnimatedSprite.flip_h=false 
		else:
			$AnimatedSprite.flip_h=true
		$AnimatedSprite.play("Corona")
		velocity.y+=GRAVITY
		velocity=move_and_slide(velocity, FLOOR)
		
	if is_on_wall():
		direction=direction*-1
		$RayCast2D.position.x*=-1
		
	if $RayCast2D.is_colliding()==false:
		direction=direction*-1
		$RayCast2D.position.x*=-1
		
	if get_slide_count()>0:
			for i in range(get_slide_count()):
				if "Player" in get_slide_collision(i).collider.name:
					get_slide_collision(i).collider.dead()


func _on_Timer_timeout() -> void:
	queue_free()
	
func _on_Long_Jump_body_entered(body: Node) -> void:
	queue_free()

I tried doing various things and got error every single time.

:bust_in_silhouette: Reply From: Mrwaffleman

I am not at all experienced but what I do know is that you might want to try a “disabled” script. Like $portal.disabled = true when the boss is alive and when it’s dead you do a false.
I not good at explaining but hope this helped

Thank you my friend. Even though I didn’t exactly followed this, your message helped me to solve my prob. I just made a Boolean in portal script and set it to false and changed it to true once the boss was dead. This Worked !

Scavex | 2020-05-27 16:32

Can you please send the script if I wanna use it for a Future project

Mrwaffleman | 2020-05-27 16:44