#Attack doesnt work

1 messages · Page 1 of 1 (latest)

rose oyster
#

When attack speed goes high, mobs sometimes ignore the hitbox(or just frame skipped)
I set the hitbox to move back and forth and when It goes faster the enemy doesnt get hit

This is my hitbox

class_name OhhHitBox
extends Area2D

func _ready() -> void:
    Global._update_damage()     # 자동으로 Damage 계산해둠
    print("데미지는 " + str(Global.OhhDamage)) # <- this is for the debug 


func _init() -> void:
    collision_layer = 2
    collision_mask = 4

and this is the hurtbox

class_name YourHurtBox
extends Area2D

func _init() -> void:
    collision_layer = 4
    collision_mask = 2
    
func _ready() -> void:
    area_entered.connect(_on_area_entered)

func _on_area_entered(area: Area2D) -> void:
    if area is OhhHitBox:
        var hitbox := area as OhhHitBox
        get_parent().take_damage(Global.OhhDamage)
    elif area is SusHitBox:
        var hitbox := area as SusHitBox
        get_parent().take_damage(hitbox.damage)

and this is the attack method


func attack():
    if is_dead or is_attacking:
        return
    is_attacking = true

    anim.play("AttackMotion")
    anim.speed_scale = Global.Ohhattack_speed
    await anim.animation_finished
    anim.speed_scale = 1
    if not is_dead:
        anim.play("Standing")
    is_attacking = false

    if is_pressing and not is_dead:
        attack()

    
broken sail
#

you're right -- Areas don't (can't?) interpolate, so if you're moving hitboxes or hurtboxes far enough or fast enough, hurtbox/hitbox overlaps might not trigger.

#

especially if the movement is happening in animation, since animations run during _process by default, but you're attempting to move _physics objects