Edit: I changed the way that gravity was applied so that it is applied even when a player is standing on a block, so instead of the game outputting that you are stepping on a tile as true and false (because if it is true gravity isn't applied, and it is moved out of collision thus in the next frame it does not collide) so now I'll be easier to check if the player is still colliding with a moving tile. I think that I will make a bool that checks if the player was colliding with the tile in the last frame, and if so set the velocities to equal that of the tile plus whatever they are doing (jumping, gravity, walking left and right).
I am trying to create moving tiles such as the ones in basically any platformer. The game is a 2d sidescroller, and the problem that I am running into is handling standing on moving tiles.
The tiles are stored in a vector, but I am unsure how to make it so that the play will have the same y and x velocity as the tile they are standing on, as well as not fall off it.
I was thinking of creating a pointer to the tile they are colliding with on the top (that is standing on it) and setting the velocities to be equal to that plus whatever the player presses (so going left or right or jumping).
However, I am unsure how to check if they collide and how to check if the player had jumped off the tile. I know how to check if the player's collision is at the top using half widths and half heights, but beyond that is a mystery.