Animation on key press - no behaviour - only events

0 favourites
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Using timer behaviour would make it easier..

    A waited event will still run if inbetween things have changed..

  • LittleStain

    Well nope, thats not working either with the on animation idle02 finished --> set animation to idle.

    Not only that, but now that I have set a random(4,8) timer, once I press a key and get a different keyboard input than 5, and hold it for the longest amount from the random number, in this case more than 8, and I let go, the idle02 frame pops in instantly (just for 1 frame) instead of starting to wait random(4,8) on letting go of any key and leaving input keyboard 5.

    Here is the capx:

    https://www.sendspace.com/file/c72ipj

    As of now, the animation idle02 is played without pressing anything between random(a,b) in my example random(4,8), but just its first frame.

    And like I wrote in the previous paragraph, once a key is kept pressed beyond the max number in the random timer, the animation idle02 pops for 1 frame instantly, and doesnt wait the 4-8 seconds.

    So this is broken in two places...

    To illustrate what I would like:

    No buttons pressed - playing animation idle -> just 1 static frame

    -----------> while animation idle is playing, every random(a,b) seconds play idle02 once, untill animation idle02 is finished,

    -----------> animation idle02 finished, go back to play animiation idle, to finish off the loop

    Now:

    If either animation idle or animation idle02 is being played, on any key press switch to animation according to that key.

    If after any amount of time that key that was just pressed is let go (can be after 4 seconds or after 1 minute etc.), go back and play idle animation, and go back to wait random(a,b) to play animation idle02, and the loop above.

  • Event 17 can never be true, because how can an animation that isn't playing finish?

    Also event 15 is still triggered every tick keyboardinput = 5, so animation is set to idle every tick..

    You seem to be missing some basic knowledge on how events and conditions work..

    animation idle2 is not playing should be a condition of event 15, not a subevent..

  • I am sure missing something if I cant get this to work thats for sure.

    The on animation idle02 is finished is nested inside the set animation to idle02 condition, so it should be only active when the set animation to idle02 is met? Do the conditions not go one after the other in the way they are nested? In the subcondition there is : play idle02, and then there is another subcondition once that play idle02 condition is met. I thought this is the way these conditions work?

    Anyway now that Ive changed as you suggested it seems to work fine.... untill you hold a movement key longer than the max value in the random(a,b) timer. So if random(4,8) and I hold a motion key 8 seconds or longer and then let go, instead of idle playing and then after random(4,8) going into idle02, now it plays idle02 instantly.

    Once more here is the capx:

    https://www.sendspace.com/file/n5wy6z

  • I am sure missing something if I cant get this to work thats for sure.

    The on animation idle02 is finished is nested inside the set animation to idle02 condition, so it should be only active when the set animation to idle02 is met? Do the conditions not go one after the other in the way they are nested? In the subcondition there is : play idle02, and then there is another subcondition once that play idle02 condition is met. I thought this is the way these conditions work?

    I guess you understand an animation can not finish if it is not playing..

    You have an event checking if an animation is not playing, subevents of that condition will only run if the animation is not playing..

    There's an explanation in the manual:

    How events work

    As I tried to explain before, the wait action makes the actions wait and they will run once the wait is over..

    So ofcourse they will run if the wait is longer than the time before returning to the idle..

    Using a timer behaviour would be much better in this case..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes I understand that an animation cannot finish if its not playing, but I thought that nesting conditions make them run only when an IF statement in the above condtition to that of the nested is true, in this case - play idle02 is higher than on idle02 finished. This would be much more intuitive:

    Every random (a,b) set animation to idle02

    -------------->On animation idle02 finished.... <-------------- run this only when the IF on top is met, in this case when animation is set to idle02....

    Now does that not makes sense?Well to me it does as this is a condition and a sub condition which should be ran only after the condition above is met... Since I am a character animator and an illustrator and not a programer (hence using visual programing) this makes much more sense to me...

    Anyhow Im not too keen on running the timer as I dont want to use built in behaviours. Ill try to look around and try and solve this.

    Thanks for your time and help.

  • Yes I understand that an animation cannot finish if its not playing, but I thought that nesting conditions make them run only when an IF statement in the above condtition to that of the nested is true, in this case - play idle02 is higher than on idle02 finished. This would be much more intuitive:

    Every random (a,b) set animation to idle02

    -------------->On animation idle02 finished.... <-------------- run this only when the IF on top is met, in this case when animation is set to idle02....

    Now does that not makes sense?Well to me it does as this is a condition and a sub condition which should be ran only after the condition above is met... Since I am a character animator and an illustrator and not a programer (hence using visual programing) this makes much more sense to me...

    Anyhow Im not too keen on running the timer as I dont want to use built in behaviours. Ill try to look around and try and solve this.

    Thanks for your time and help.

    Yes, what you say makes sense, that's why the subevent you created doesn't..

    If the event above is true, there is no animation playing..

    When the actions attached to that event have run, the animation is playing, but at that time the event/conditions aren't true anymore..

    So the subevent will only run if the above event is true..

    A sprite can't be playing an animation and not be playing an animation at the same time..

    You reference a sprite in the top-event that isn't playing an animation, so the sprite in the subevent must be not playing an animation as well..

    This is how events work, that's why I added that link, for it is explained very clearly there..

    I'm not sure why you would choose not to use built in behaviours, but if you don't want to, you could make a timer yourself by using the:

    wallclocktime

    The number of seconds since the game started, not taking in to account the time scale (i.e. the real-world time).

    just set a variable to the wallclocktime and when the wallclocktime is higher that a certain amount, bladibla..

    (But you would need another variable, ofcourse..)

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