Private Variable problems

For questions about using Classic.

Post » Sat Sep 25, 2010 5:56 pm

I'm working on getting a fighting game working and it's (or was) moving along nicely, but I've hit a snag.

I have four variables which I use for jumping: jumpForward, jumpBackward, jumpStanding and doubleJump

The idea is that if any of them, except doubleJump, is equal to 1, the player input is ignored and the player is moved forward, backward or not at all (depending which variable is at 1) until the character either jumps again or lands on ground, at which point the variables are set to 0.

Here's the problem, the variables are always set to 0. I've checked with the debugger and they don't change at all. Or if they do, they turn back to 0 too fast for it to be seen. This is not supposed to be and I can't seem to find any events that does this, aside from the 'on ground' event.

Here's the cap
http://www.box.net/shared/fxbi0mm7p8

The problem is in the 'testlevel' layout.
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Sat Sep 25, 2010 6:32 pm

I think the problem is the variables never get set to 1. All the events that set the variable require that doublejump=1 including the event that sets doublejump to 1.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Sat Sep 25, 2010 7:06 pm

I just put in doubleJump yesterday. Must have missed that. I changed it so that it's 'equal to 0' now.
However, there's still a problem. After I made the change I checked again with debugger and the variables do change as they are supposed to now (well, sort of. It's still a bit iffy...), but they still reset to 0 almost instantly for no apparent reason because the 'is on ground' event is the only one that sets them to 0. Unless I'm missing something.

New cap: http://www.box.net/shared/4qtnahjoke
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Sat Sep 25, 2010 8:00 pm

Change this condition
+ player1_MSK: is on ground
to this
+ player1_MSK: [negated] is jumping
+ player1_MSK: [negated] is falling

"is on ground" sets the vars to zero when jumping because is seems that the object is still considered on the ground at the beginning of the jump.

Also I found a typo on the "player2" event sheet, on event 3.
+ System: Else
-> PlayChar2: Set angle to 0
-> System: Disable group "P1 F Right"
-> System: Enable group "P1 F Left"

I'm pretty sure those "P1"s need to be "P2", otherwise it causes the player1 to bounce in the air when jumping over player2.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Sat Sep 25, 2010 8:42 pm

[quote="R0J0hound":2eiahoy3]Change this condition
+ player1_MSK: is on ground
to this
+ player1_MSK: [negated] is jumping
+ player1_MSK: [negated] is falling

"is on ground" sets the vars to zero when jumping because is seems that the object is still considered on the ground at the beginning of the jump.[/quote:2eiahoy3]
Ah, should've known. But this raises a question. This sort of makes the 'on ground' condition pointless. Why does it exist?

Over to the other thing you mentioned. It's actually not a typo at all.

What I wanted to do was to have the events that change your facing in one group and the controls for facing left in one group and facing right in another. If you face left then the group for facing right is disabled and vice versa, and when you're in the air the group with the events that changes your facing itself is disabled.

I knew that it bounces and have been trying to solve it (the everything gets set to 0 kind of got in the way)... .But strangely it only bounces when you try to jump from player 2's left side to its right side. Jump from right to left seems to work nicely.
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Sat Sep 25, 2010 9:17 pm

This should fix the bouncing.
Changed event #3 of event sheet "player1". The var JumpBackward was used twice and JumpForwad wasn't used.
Changed event #3 of event sheet "player2". This was the issue I was talking about. The player1 facing was being changed from player2 events.

[url:2kochhgh]http://dl.dropbox.com/u/5426011/examples2/FighterGame%20fix.cap[/url:2kochhgh]
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Sat Sep 25, 2010 9:30 pm

Oh yeah, I misread your post, you were completely right on the typo there.
B
73
S
20
G
10
Posts: 524
Reputation: 9,896


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests