Thank you. It turned out the sliding was actually caused by another part of my code (Without it I stay on the platform properly), which I'm also unsure on how to fix:
The problem is this:
I'm applying my own gravity to the player. The gravity-force (As well as player movement) is applied to a velocity vector stored on the player object (Let's call it m_internalVelocity), which is used for the displacement in the move-calls. However, this results in the following issue:
1) Player is on ground
2) Gravity force(0,-50,0) is added to m_internalVelocity
3) m_internalVelocity is applied through move-call
4) Physics are simulated
5) m_internalVelocity is obviously still (0,-50,0), even though the actual velocity is (0,0,0), because the player is on the ground and cannot move downwards
6) Gravity force is added again, new m_internalVelocity is (0,-100,0)
7) etc
So basically the velocity would just increase infinitely. For this reason I'm grabbing the actual velocity after the simulation by comparing it with the previous velocity before the simulation:
1) Player is on ground
2) Player actor's current velocity is stored in a variable -> oldVelocity(0,0,0)
3) Gravity force(0,-50,0) is added to m_internalVelocity
4) m_internalVelocity is applied through move-call
5) Physics are simulated
6) I compare the new velocity of the actor with oldVelocity -> Since the player can't move downwards, the velocity I get here is (0,0,0), which is correct
7) m_internalVelocity is set to the delta velocity (0,0,0)
8) etc
This worked so far, but doesn't work if there's outside forces like a moving platform in this case:
1) Player is on moving platform
2) Player actor's current velocity is stored in a variable -> oldVelocity(0,0,0)
3) Gravity force(0,-50,0) is added to m_internalVelocity
4) m_internalVelocity is applied through move-call
5) Physics are simulated
6) I compare the new velocity of the actor with oldVelocity -> The velocity I get here is the movement that was caused by the platform
7) m_internalVelocity is set to the delta velocity (Platform movement)
8) In the next move-call the m_internalVelocity will be applied again which means the platform-movement is essentially added a second time
9) With every simulation the platform-movement is added to the previous m_internalVelocity, causing the player to keep increasing velocity until he falls off the platform
How can I keep track of the player's internal velocity (Character movement +gravity) without affecting outside forces(platform), but still retrieving changes caused by physical contacts between the controller and other actors?