Issue with control inputs

For questions about using Classic.

Post » Sun Dec 05, 2010 4:45 am

Hey everyone, new guy here and really having fun getting into Construct.

The problem appears to be very small, but I can't locate the issue for the life of me. I've built a system in the event editor that allows the player to put the character in a variety of states (walking, running, crouching, etc.) I have it set up so that when the player presses the crouch button, the character crouches...the system recognizes that the character is in the "crouch state," the animation changes to reflect this, etc. It works just fine, with one small issue; the very first time you press the button, it is not recognized. However, it works perfectly every subsequent time.

I was really confused by this, so I actually deleted everything else in the entire event list except the couple of events needed to actually do the crouch and this still happens. I also tried changing which key the command is assigned to and this makes no difference either. Any ideas?
B
4
G
2
Posts: 2
Reputation: 754

Post » Mon Dec 06, 2010 8:42 pm

I see no one seems to have any ideas, so I'll try to clarify a little bit.

On the player sprite I've created a private variable that detects when the player is crouching. At 0 he is not, at 1 he is. The player toggles this state by hitting the "shift position" control, which I've currently got set to shift. Whenever the crouching state variable is at 1, the animation/speed/etc all change to reflect this. It works like a charm with the exception of the very first press of the shift key...you must tap the key twice to get the player to crouch the first time, every other time it works just fine.

Any ideas?
B
4
G
2
Posts: 2
Reputation: 754

Post » Mon Dec 06, 2010 10:02 pm

Hi,
A posted cap along with a description of the problem always gets a solution faster than just a description.
I recreated what you described in your second post and it work fine.
[code:1ziy5fze]+ MouseKeyboard: On key Shift pressed
+ Sprite: Value 'crouching' Equal to 0
-> Sprite: Set 'crouching' to 1
+ System: Else
-> Sprite: Set 'crouching' to 0
+ Sprite: Value 'crouching' Equal to 0
-> Sprite: Set height to 50
+ Sprite: Value 'crouching' Equal to 1
-> Sprite: Set height to 25[/code:1ziy5fze]

In your cap is the initial value of the crouching variable set to one of the two 0,1 or is it another value. It may just be something that's amiss with the order of your events, although I can't say for sure. If you post the cap a solution should be found fairly quickly.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest