0 votes

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:

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

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():
    if hp<=0:


func _physics_process(delta):
    if is_dead==false:
        if hp<=15:

        if direction == 1:
        velocity=move_and_slide(velocity, FLOOR)

    if is_on_wall():

    if $RayCast2D.is_colliding()==false:

    if get_slide_count()>0:
            for i in range(get_slide_count()):
                if "Player" in get_slide_collision(i).collider.name:

func _on_Timer_timeout() -> void:

func _on_Long_Jump_body_entered(body: Node) -> void:

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

in Engine by (413 points)

1 Answer

0 votes
Best answer

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

by (44 points)
selected by

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 !

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.