I am using speculative contacts for my platformer physics and it works great, but there is a small thing which bugs me a lot.
When i climb up a 45 degrees slope the body slides down due to gravity - which is totally fine, but i want to have the ability to climb up the slope without any sliding at all.
I tried disabling the gravity when i detect "i am on the slope", which solves the sliding issues partially, but these will create ugly collision bugs :-(
My goal is to control when i slide and when i dont - which is not physically correct, but makes it much more fun.
Also i dont have any physical friction at all - i manually do friction for (on ground, in air, changing direction, standing etc.) like this:
// We are on ground when the collision systems says so
boolean grounded = state.player.collisionState.contains(CollisionState.Ground);
// Apply ground friction
float friction = 1f;
if (grounded) {
if (Math.abs(state.player.acc.x) > 0) {
if (state.player.acc.x < 0 && state.player.vel.x > 0) {
friction = state.player.groundAccelTurnFriction;
} else {
friction = state.player.groundAccelFriction;
}
} else {
friction = state.player.groundDefaultFriction;
}
} else {
if (Math.abs(state.player.acc.x) > 0) {
if (state.player.acc.x < 0 && state.player.vel.x > 0) {
friction = state.player.airAccelTurnFriction;
} else {
friction = state.player.airAccelFriction;
}
} else {
friction = state.player.airDefaultFriction;
}
}
state.player.vel.x += state.player.vel.x * -1f * friction * GameTime.dt;