do after n seconds

0 favourites
  • 4 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
  • How do "I do after n seconds" do something?

    What I am trying to achieve is "do every n seconds until xxx happens" for movement, using recurrence.

  • The easiest way I've found you can achieve this is the following:

    * Create a global variable and call it something like: "ActionHappened" and set it's default value to 0.

    * Create a timer that runs every x seconds if the variable ActionHappened = 0

    * Elsewhere you would have your action set the value of ActionHappened to 1 whenever the action you are waiting on has been triggered

    * Then on your earlier timer function I would put an else and then perform whatever code actions you want to perform

    If you need further explanation, just ask.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Works inefficient. The whole idea behind my movement is to do the check every x seconds only if ActionHappened=0. Your solution would still be checking the condition even after ActionHappened=1. For movement ActionHappened == If The player have reached the point pointed by mouse do set ActionHappened to 1.

    What I am trying to achieve:

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> Yes <System> Ok it's fine. I won't be troubling you again.

    What I get using your solutio:

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> NO <System> I move Player towards target.

    <SYstem>Are you there? <Player> Yes

    <SYstem>Are you there? <Player> Yes

    <SYstem>Are you there? <Player> Yes - Yes for f*ck sake's I am where I should be so shut the f*ck up!

    I will be doing RPG so I can allow myself to have one useless "Every thick" running but I wonder what will happen if need to do Paltfromer with plenty of things running.

  • i would create a variable lets call it x = 0

    ok so your example lets say when the system says are u there and you say "yes" event will be x=1

    and under condition it would be "every n seconds' aswell as "if x = 0" ask "are you there"

    sorry im bad at explaining but that should work for what u need

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