Stop commands for a period of time?

0 favourites
  • 14 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I'm trying to figure out if there is a way to "freeze" the character (but not his animation) for exemple for 1 or more (or less) seconds

    for exemple

    if the character is hitten by something it will stop working for 0.3 seconds

    there is a way do make this kind of function?

  • you mean freezing like not reacting to the userinput?

  • not reacting to the user imput is something like "ignoring user imput"

    but the problem is to make it last some seconds, no matter the input of the user

  • one way, that pops in my mind is to create a timer, that fires every 0.1 seconds and increases a global variable.

    Then at the moment of the freez, you store this global into a local and have another event check, if the local + 0.3 is reached by the global...then you can un-freeze

  • it would work even to create a timer that check if the desired value is reached every 0.1 seconds, and if not it will increase the value and retry maybe?

    maybe something like:

    System: Every 1.0 seconds (1.0 because it's more visible)

       Sprite: timer < 3

       --> Sprite: add 1 to timer

       Sprite: timer = 3

       --> Sprite: stop ignoring platform user input   

       --> Sprite: set timer to 0

  • sure....I just think its a good idea to create an "overall" usable timer. Just be warned, an increase of 0.1 seconds, ie. increasing the variable 0.1 can go by undedected - just happend here - so you should check a range like 3.0 to 3.5 seconds....

  • Somehow I've managed the problem (for now >,<)

    Thanks for the help ;)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think a much easier way might be to use the system 'Wait' action!

    + On some event

    -> Set ignoring input

    -> Wait 1 second

    -> Set not ignoring input

  • I think a much easier way might be to use the system 'Wait' action!

    + On some event

    -> Set ignoring input

    -> Wait 1 second

    -> Set not ignoring input

    Honestly Ashley - IMHO there are only a few people out there that really understand how WAIT works. I think I have a slight idea how it works and its designed and still I stumble over unpredictable behaviour, so I try to establish almost everything avoiding WAIT!

  • I think a much easier way might be to use the system 'Wait' action!

    + On some event

    -> Set ignoring input

    -> Wait 1 second

    -> Set not ignoring input

    It's good and it actually seem to work well for my purpose ;)

    and since I can't see any sort of bug for now and I've ended the event limit for the free version of the program, this is way shorter and suitable than the other ;P

    Thank You!!

    [I don't know what kind of issue the wait function may generate btw but I couldn't see any problem untill now]

  • I don't see how 'Wait' can be hard to understand, Its pretty self explanatory <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I don't see how 'Wait' can be hard to understand, Its pretty self explanatory <img src="smileys/smiley1.gif" border="0" align="middle" />    

    ...sure, as long as you do not use it in LOOPS.....

    But this seems to be just me <img src="smileys/smiley18.gif" border="0" align="middle" />

  • Weishaupt, you can use Wait in loops, the problem is most people do this:

    + Repeat 10 times

    -> Do something

    -> Wait 1 second

    This doesn't work. I've tried explaining this a few times now, but maybe one more time: 'Wait' actually means 'set up a timer to run the rest of this event in X seconds'. So if there's nothing after the Wait action it will have no effect at all. This event says "repeat 'do something' 10 times, then wait 1 second and do nothing 10 times". Instead what you usually want is:

    + Repeat 10 times

    -> Wait loopindex seconds

    -> Do something

    This works, because loopindex goes 0, 1, 2, 3... so each iteration waits a different amount of time. The end result is the action is run one second apart for ten seconds, which is probably what you wanted. In other words, the event says "starting from now, wait 0 seconds then do action, wait 1 second then do action, wait 2 seconds then do action...".

    You probably think of 'Wait' as pausing the entire game for an amount of time. It would be useless if it did that! The entire game would freeze while the loop was running. It's only useful to have it work this way round. I hope you can see how it works better now :) I'm not aware of any bugs in the Wait action, it's just people assume it means 'pause game'.

  • I think I have now "completly" understood how it works. Thank you for your patience.

    May I suggest renaming "WAIT" to "WAIT to exec the FOLLOWING".....or something similar - sorry english is not my mothertongue <img src="smileys/smiley5.gif" border="0" align="middle" />

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