Enemy behavior with instance variables

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm trying to have the enemies in my game jump every X seconds, based on individual value set on each enemy. The enemies use platform behavior (well, PlatformPlus to be exact) and I added an instance variable to the enemy sprite to control the frequency of the jump. ("every ENEMY.frequency seconds" -> "ENEMY simulate PlatformPlus pressing jump")

    This works with one enemy, but when there are multiple enemies they all jump based on the frequency value on the first enemy, instead of their own. I tried adding "for each" condition but that only resulted in the first enemy jumping and the other enemy standing completely still. I've probably overlooked something here as there must be a simple solution to this, any help would be greatly appreciated!

    Also, I would like to have another instance value for the enemies for delay/offset seconds (so if for example two enemies have their jumping frequency set to 4 seconds, and the other one has delay set to 2 seconds, it will wait 2 seconds before proceeding to jump whereas the first one with delay value of 0 will jump instantly. What would be a good way to implement this kind of behavior? Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • add timer behavior

    on enemy create start timer"jump" random(2,4) (once)

    for each enemy

    ontimer "jump" :simulate jump and start timer "jump" random(2,4) (once)

  • ..

    Thanks MadSpy and sorry about the late reply, I've been very busy with work and have not had much time for game dev last couple of weeks, sadly Hope to get back to more active development soon! But I just tried and that seems to work and fix the issue I had with the enemies, so thanks a lot!:)

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