0 votes

I made a fire ball that my player can shoot and i made a enemy that can also shoot fire ball.
I made that the fire ball has a life and velocity and when he meet another fire he adding accelaration to the other fire ball and subtracting its velocity.
So when two fire balls meet the boths stay in the same place but moving a little and both of their life get reduce and when they life riches zero the both should disappier.
But its giving me this error.
I think its giving me this error because the dissapier at the same time so when one dissapier the other still thinks its exists and call a function on him.
How can i fix this?

fire ball code:

extends KinematicBody2D
onready var hurtbox = $hurtbox
var acc : float = 400.0
var facing : int = 1
var damage = 15
var techniqueDamage = 50
var controller = TechniqueSceneHandler.new()
#func _ready():
#   print("use")
func _physics_process(delta):
    var areas = hurtbox.get_overlapping_areas()
    for area in areas:
        if area.name == "hitbox":
            var parent = area.get_parent()
            if parent != self:
                if parent.is_in_group("Technique") and parent != null:
                    print("here")
                    parent.controller.addForce(Vector2.RIGHT * acc * facing)
                    parent.controller.subtractLife(techniqueDamage * delta)
    updateFlip()
    controller.addForce(Vector2.RIGHT * acc * facing)
    controller.update(delta)
    controller.velocity = move_and_slide(controller.velocity)

func updateFlip():
    scale.x = scale.y * facing
func _on_Timer_timeout():
    queue_free()
func get_damage() -> float:
    return damage
func _on_hurtbox_area_entered(area):
    if area.name == "hitbox":
        var parent = area.get_parent()
        if parent != self:
            if parent.is_in_group("Technique") and parent != null:
                parent.controller.velocity = Vector2.ZERO
Godot version 3.2.3
in Engine by (12 points)
recategorized by

Never mind, i was able to solve this

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.