Animation on key press - no behaviour - only events

Get help using Construct 2

Post » Thu Dec 31, 2015 6:14 pm

The thing is that the idle animation is only 1 frame long, and I want it to last for the minimum amount of seconds that I am inputing in the random(A,b).

https://www.sendspace.com/file/4uxvcm


Here is the file as you can see at this moment the animation Idle02 plays on 1 frame and then is switched back to Idle.
When I add on "finished animation" for Idle02 play idle, that causes the moving animation not to be stopped when no buttons are pressed and inputkeyboard=5 kicks in, but keeps on playing the moving animation until the moving animation has ended.
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Dec 31, 2015 6:37 pm

You do know every x seconds is counted from the start of the game and not from the moment the condition becomes true?

it would probably be better to use wait or timer behaviour to accomplish this..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 6:58 pm

LittleStain wrote:You do know every x seconds is counted from the start of the game and not from the moment the condition becomes true?

it would probably be better to use wait or timer behaviour to accomplish this..


@littleStain
Of course you are right, but in this situation it doesnt matter as both arent working as you will see in the attached capx where I have changed to wait random(a,b):

https://www.sendspace.com/file/bcmrqg
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Dec 31, 2015 7:20 pm

Well ofcourse this doesn't work..
every tick keyboardinput is 5, the animation is set to idle..

if you add the condition

sprite is not playing animation "idle02"

it swiches animations

adding the event

on animation "idle02" finished
>set animation to idle

will make the switch complete
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 7:32 pm

@LittleStain

Thanks for your time.
Hmm, but the wait random(a,b) to play other animation is set within the keyboard input 5, does it not go down the condition branch every a,b seconds then?

As the idle animation has 1 frame, when I add the "set animation to idle" it will automatically play idle02 once again.
Anyway I will try what you suggested first along with the random(a,b) then Ill get back to you.
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Dec 31, 2015 8:12 pm

Using timer behaviour would make it easier..
A waited event will still run if inbetween things have changed..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 8:24 pm

@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.
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Dec 31, 2015 8:49 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 9:04 pm

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
Brick by brick, stone by stone.
B
52
S
24
G
17
Posts: 273
Reputation: 12,663

Post » Thu Dec 31, 2015 9:20 pm

Solomon wrote: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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests