[UnSolved] Every X Seconds Issue

0 favourites
  • 7 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • I am having a slight issue. I have code that tests for two objects distance, Enemy and Player. If Enemy is within the distance of the Player to be able to attack I have the code set to Every X Seconds, X being the Enemies Agility Variable, call upon the attack function. The problem is this only works for which ever enemy my player walks into range of first. If I am surrounded by more then 1 enemy their Every X Second commands do not work until the first is destroyed. As this would be ok in a turn based game, I need help making it so it will run it independently, so I can be in range of various Enemy objects with different times and have it all work together.

    The code I have right now is

    distance(enemy.x,enemy.y,player.x,player.y) <= 800

    -- Every Enemy.AGILITY seconds:: Call Attack Function

    Thanks in advance guys!

    (Side Note. I have tried the For Each condition hoping that would work, however it did not... Perhaps I am using it wrong?)

  • You should use the Timer behaviour instead. It times each instance. Every X seconds is a global mechanism.

  • You should use the Timer behaviour instead. It times each instance. Every X seconds is a global mechanism.

    I've tried to implement the timer behaviour and I failed... Any quick tips on how I should organize it?

  • From the Top-down Shooter template. Give Enemy an InRange boolean and the Timer behavior. Event 9 sets up the behaviour, by distance. Event 13 does the attack.

    http://www.blackhornettechnologies.com/ ... r_BHT.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • From the Top-down Shooter template. Give Enemy an InRange boolean and the Timer behavior. Event 9 sets up the behaviour, by distance. Event 13 does the attack.

    http://www.blackhornettechnologies.com/ ... r_BHT.capx

    I copied the code exactly but it offers the same issue as Every X Seconds does. It takes the lowest timer time of both the enemies and only one of their damage gets subtracted from the health at a time. You need to kill enemy A for enemy B to attack.

    Anyway to sort this out?

  • run blackhornet 's capx and just work your way through it - this works as expected (nice pulse effect by the way)

    If you are calling a function in your code then you may need to tell the function which enemy is expected to fire...

    firstly try re-writing to not use a function and see if it works...

  • run blackhornet 's capx and just work your way through it - this works as expected (nice pulse effect by the way)

    If you are calling a function in your code then you may need to tell the function which enemy is expected to fire...

    firstly try re-writing to not use a function and see if it works...

    I don't understand... I deleted what I had and put it back in exactly as I had already copied blackhornets code exactly and it works now... I'll chop it up to me not paying attention to something, perhaps maybe it was the function. Either way gentlemen I am in some serious gratitude, thank you so unbelievably much!!

    Have a good night!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)