0 votes

i have been working on an action rpg and have just finished the title screen, however, whenever i get hit by an enemy or i hot an enemy, the game crashes. i have figured out what is wrong, but i dont know how to fix it. i have made the hit effect appear on the main scene, but my title screen is now the main scene. how do i make it appear on the current scene?


in Engine by (14 points)

You should share the relevant code, otherwise it will be difficult to determine what you've done wrong.

sorry, i should have done that. this is the code that has the problem:

extends Area2D

const HitEffect = preload("res://Effects/HitEffect.tscn")

var invincible = false setget set_invincible

onready var timer = $Timer

signal invincibilitystarted
signal invincibility

func setinvincible(value):
invincible = value
if invincible == true:

func start_invincibility(duration):
self.invincible = true

func createhiteffect():
var effect = HitEffect.instance()
var main = gettree().currentscene
position = global_position

func onTimer_timeout():
self.invincible = false

func onHurtboxinvincibilitystarted():
set_deferred("monitorable", false)
monitorable = false

func onHurtboxinvincibilityended():
monitorable = true

i added a title screen, which made that the main scene, thus the game tried to put the efect on that scene. i think that is what happened at least.

1 Answer

0 votes

Without looking at what you're doing it's difficult to answer your question.

Here's a way you can add something to the current scene:

by (25 points)
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.