Platforming & order of events problem

For questions about using Classic.

Post » Thu Dec 30, 2010 6:24 am

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?
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Thu Dec 30, 2010 6:43 am

Is there anyway you could incorporate both movements into one block of code, that references the respective players? Or perhaps use a family?
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Fri Dec 31, 2010 3:42 pm

[quote="Tokinsom":37ls3lcs]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.[/quote:37ls3lcs]

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.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sun Jan 02, 2011 4:32 pm

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)
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sun Jan 02, 2011 8:21 pm

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.

[code:yk2pb1go]
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]



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 should be 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.)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Jan 02, 2011 8:51 pm

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.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest