0 votes

i have 2 tower one magic and other basic damage, i make display when they hit. if one type tower everything seem ok, but when two type tower hit enemy, my display messup, its ok when one type hit at time, but when both hit at same time, the display change between magic display and basic damage display at middle display play,
for example
first , when first tower(basic damage) hit display value come out with red color, but before animation finish , second tower(magic damge) hit another enemy both value change color to blue

how should it fix it?


extends Control

var damage_display :int 
var critical_damage: bool = false
var magic_damage : bool = false

func _ready() -> void:
    if critical_damage == true:
    elif magic_damage == true:

func _process(delta: float) -> void:

    $damage_disply.text = str(damage_display)
    if $damage_disply.self_modulate ==Color("00ffffff"):

func damage_value(value,crit,magic):
    damage_display = value
    critical_damage = crit
    magic_damage = magic


func on_hit(min_damage,max_damage,crit_chance,crit_on_off,magic_on_off):

    var damage_type :int # can choose crit/magic/normal formula

    var ad_random_damage = int(rand_range(min_damage,max_damage))
    var ap_random_damage = int(rand_range(min_damage,max_damage+999))
    var random_pos =randi()% 3+1
    var crit_damage_value = ad_random_damage + int ( rand_range(min_damage,max_damage))

    var magic_damage_display :bool = false
    var crit_damage_display : bool = false
    var crit_random_change : float = randf() #random float for crit 

    if crit_on_off == true:
        hp -= ad_random_damage
        damage_type = ad_random_damage
        if crit_random_change <= crit_chance:
            hp -= crit_damage_value
            crit_damage_display = crit_on_off
            damage_type = crit_damage_value
    elif magic_on_off == true:
        hp -= ap_random_damage
        magic_damage_display = magic_on_off
        damage_type = ap_random_damage

bullet 1

func _on_bullet_body_entered(body: Node) -> void:
    if body.is_in_group("enemy"):
        body.on_hit(min_damage,max_damage,crit_chance,crit,magic)#min_damage,max_damage,crit_chance,crit on/ of,magic on/ of

bullet 2

func _on_skill_body_entered(body: Node) -> void:
    if body.is_in_group("enemy"):
        body.on_hit(min_damage,max_damage,crit_chance,crit,magic) #min_damage,max_damage,crit_chance,crit on/ of,magic on/ of
in Engine by (416 points)

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.