Hello. I was thinking how to fix one problem with collisions and gravity. Here is how my code looks:
if(falling){
yVelocity -= Scene.GRAVITY * delta;
position.y += yVelocity * delta;
}
falling = true;
for(Model m : scene.getModels()){
CollisionModel cm = m.getCollisionModel();
if(cm != null){
if(cm.checkSphereCollision(position, playerRadius)){
falling = false;
yVelocity = 0.0f;
}
}
}
So now if I would fall on ground it would be okay, but if I jump and walk to the wall it sets falling = false and it doesn’t falls anymore. Should I check whether colliding plane is ground or wall by checking it’s normal vector or there is any other way to solve this problem? Here is a video of how it looks: https://www.youtube.com/watch?v=lQMRr6o7xTc