How To Make An Automated Enemy Attack When In Range

Discussion in 'How Can I...?' started by brecon1313, Aug 21, 2022.

  1. brecon1313

    brecon1313 Boxer

    Jul 22, 2022
    Likes Received:
    Hello! I am trying to make a simple attacking system for my game in a 2D Buildbox 3 world. I have enemies that automatically fly towards the character, but once in range, I would like it to attack the character. Here's a breakdown of an attack system I'm trying to implement, but having trouble fixing. (Photos are attached)

    1. An object spawns on the character when the game starts as an invisible child object
    2. When the enemy collides with this object, the enemies state is turned to attacking
    3. A hitbox for its attack is spawned and collides with the character's hitbox
    4. This sends a signal which is received by the health brainbox and damages it

    I also have a system for the character to attack:
    1. When the left mouse button is clicked, its state is turned to attacking
    2. A hitbox for the attack is spawned and collides with the enemy's hitbox
    3. This collision does damage to the character's health brainbox

    This isn't working and I'm not sure why. One of the errors I'm often getting is "_collide is null". Could someone help me out with this? Feel free to ask questions because there isn't much I can show with just a couple of pictures. Thanks!

    Attached Files:

Share This Page