Have something happen for a limited amount of time

0 favourites
  • 5 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Hi!

    What would be a good way to make an enemy walk left for say 5 seconds and after that walk right for five seconds?

    I'm controlling the enemy currently with platform controls and on every tick -->simulate control -->left. I can't seem to figure out a good way of making it move for a limited time only.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are many different ways you could do this and it's probably worth checking through the FAQ and doing a forum search to see how other people would solve this.

    For me, I would give my enemy a Boolean variable WalkingRight and put a couple of invisible obstacles on the layout where I want the enemy to change direction. I would give my obstacles each a Boolean variable as well, something like ChangeToWalkLeft - the obstacle on the right would then have this set to true and the one on the left set to false (this prevents double collisions giving you problems later).

    Then in the event sheet, the enemy controls would be:

    • if enemy.WalkingRight = true ; simulate platform press right
    • if enemy.WalkingRight = false ; simulate platform press left

    -> On enemy collision with obstacle

    ---> if obstacle.ChangeToWalkLeft = true ; enemy.WalkingRight = false

    ---> if obstacle.ChangeToWalkLeft = false ; enemy.WalkingRight = true

    I hope my text version of the events you need makes sense...

    Have a look through the FAQ as I said at the start, there are some great examples of how to do all sorts of things with C2. Enough to take up your whole weekend... <img src="smileys/smiley1.gif" border="0" align="middle">

  • Hi!

    Sorry I might not have been clear enough. I'm looking for a way to do this for a certain amount of seconds. The enemy thing was just an example. I'm trying to use that as an example of how to make something happen for a limited amount of time.

  • Aha - in that case, you need the Timer Behavior .

  • Thank you very much, that sounds like what I'm looking for! I will check it out asap.

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