Platforming & order of events problem

This forum is currently in read-only mode.
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • In my 2-player game, a player can run into the other player to knock him back a little bit. Both players get knocked back, but the one who wasn't moving, or was moving slower upon impact, gets knocked back farther.

    Problem is, player 1's "bumping" events are above player 2's, so player 1 always knocks player 2 farther back. If I put player 2's "bumping" events above player 1's, then he will knock player 1 farther back.

    I need both players to get knocked back the exact same distance when running towards eachother, or one of them will have an advantage. The problem is clearly with the order of events, but I have no idea what to do about it. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is there anyway you could incorporate both movements into one block of code, that references the respective players? Or perhaps use a family?

  • Problem is, player 1's "bumping" events are above player 2's, so player 1 always knocks player 2 farther back. If I put player 2's "bumping" events above player 1's, then he will knock player 1 farther back.

    Sounds indeed like it could be fixed by using families and/or proper branching. If you're still having issues I'd suggest to post a cap.

  • Blah. Tried a family but I'm not really sure how to use it in this situation. I recreated the bumping in this cap. Maybe someone can have a look?

    http://www.mediafire.com/?6wbegjf7fp7b3zb

    (Player 1 uses arrow keys, Player 2 uses A,D)

  • Since red and green colliding is something that can only happen once in any given tick, you only need one collision check. What you're doing is finding the first event that returns true and shutting off all collision checks that follow it by using "Bump = 1"

    Anyway, you need to think a bit more logically.

    Do they collide?
        YES
            Is the speed between the two equal?
                YES - Knock them both back 50
                NO - Check who is faster
            Is red faster than green?
                YES - Knock green back at red's speed, knock red back 50
                NO - Do the opposite
    [/code:yk2pb1go]
    
    <img src="http://i54.tinypic.com/1zqdlcm.png">
    
    Now, keep in mind that there is a bug in the platform object whereby it's speed is not constant*.  It's continuously fluctuating.  So when both players are running at what [i]should be[/i] full speed, one will almost always be going slightly faster than the other.  This means that the one who is slightly faster will get the advantage.  But this way the advantage will at least be random, instead of always favoring whoever gets top pick in the order of events.
    
    *(To test this, move both of your players to the right.  Keep holding down the movement keys.  You can see the space between them will grown and shrink.  Eventually, one may even catch up to the other.)
  • Ahhh I didn't really think about that.. Well thanks man this works great! I'll try to look over my events a bit more carefully next time.

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