What is wrong here ?! Possible bug ?

Get help using Construct 2

Post » Wed Apr 02, 2014 9:42 pm

I've encountered a problem when I tried to do the following basic action: To change a character's animation when pressing a key and change it again when pressing the same key again :shock:

Here is a screenshot with my Event Sheet:
Image

Here is the .capx file: AnimationChange.capx
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Wed Apr 02, 2014 10:03 pm

here is your capx altered

your version says

if key "X" pressed and mode="anim2" then ... and set mode to equal "anim1"

if key "X" pressed and mode="anim1" then ... and set mode to equal "anim2"

so it does the first line and finds "X" pressed and mode="anim2" so changes (animation) and sets mode to "anim1"
it goes on to now find that "X" is still pressed and mode is now="anim1" (because we have just made it ="anim1" in the last line so it changes the animation and makes modebact to"anim2" again ....

edit (3rd April,2014) to add picture of events
You do not have the required permissions to view the files attached to this post.
Last edited by RamPackWobble on Thu Apr 03, 2014 8:24 am, edited 1 time in total.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Wed Apr 02, 2014 10:17 pm

@RamPackWobble

Thanks for your fast answer, but can you explain me what I was doing wrong ? I want to organize my project in groups so when I want to modify something to know where to look.

Also, If I have more than 2 "modes", how should I structurate the events ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Wed Apr 02, 2014 10:31 pm

The reason is that when you press "X" player mode 1 triggers true. In this case you Set mode to "Anim2" causing Player Mode 2 to also trigger true right after. Pretty sure that's your problem.

Its a bit weird setup you have made.

If you make it like this instead:

On X pressed
-------> Player.Mode = "Anim1"
------------------ : set Mode to "Anim2"
-------> Else
------------------: Set Mode = "Anim1"

Then you only need 1 Group to handle the switching for you.

If you need it to handle more you just add conditions to the Else so:

On X pressed
-------> Player.Mode = "Anim1"
------------------ set Mode to "Anim2"
-------> Else
---------Player.Mode = "Anim2"
------------------ set Mode = "Anim3"
-------> Else
---------Player.Mode = "Anim3"
----------------- set Mode = "Anim4"
-------> Else
--------- Player.Mode = "Anim4"
------------------ Set Mode = "Anim5"
.. etc
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Wed Apr 02, 2014 10:42 pm

@RamPackWobble @nimos100

Thank you both very much. I understand now my error (I tried several alternative ways, but what I was missing was Else and a better structure of the events).
B
49
S
15
G
6
Posts: 534
Reputation: 7,195


Return to How do I....?

Who is online

Users browsing this forum: David181 and 18 guests