Private Variable problems

This forum is currently in read-only mode.
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • 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.

  • 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.

    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.

  • 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.

    http://dl.dropbox.com/u/5426011/examples2/FighterGame%20fix.cap

  • Oh yeah, I misread your post, you were completely right on the typo there.

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