Ahoy there, pleased to make y’all collective acquaintance. Please forgive my noobness, we’ve not been MakeCoders for very long, but the youngster would like to bring his game idea alive and I’m trying to help him figure out the bits he hasn’t quite figured out yet. This has gone pretty smoothly so far, watching tutorials and such, but we’re having an issue with multiplayer player on player collisions.
The gist of the game is a single screen 2 player battle where the players run and jump around trying to jump on each others head. If a player has been jumped on, said player will lose a life and respawn, this continues until a player has 0 lives left.
We’d like to detect collision between the bottom of a player sprite and the top of another player sprite, but we’ve only come across this kind of collision detection with player sprites on walls, where you can for example detect if the bottom of a player sprite comes in contact with a wall (see below). Is is possible to do this kind of collision with player on player sprites?
We tried to do a workaround where we’d check to see if a player sprite overlaps another player sprite and then check if the player was falling, which although not perfect, would tell us that the player was falling onto the other sprite, and might suggest that they jumped on them. However, we’ve hit a bump as it seems to only work for player 1, at first I thought it was because the code to detect the collision started with player 1, but we swapped it so that player 2 was checked first and it still only worked for player 1. The code is below:
Obviously, detecting the bottom of a player overlapping the top of another player would be ideal, but if that’s not possible, some guidance as to what we’ve done wrong with the workaround would be greatly appreciated. Thanks kindly for your assistance. May the universe throw good times in your general direction and all that jazz!