Collision and gravity

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

Can’t you just store whether each object is a floor or a wall and do the calculation based on that boolean?

No. I have object editor created for my game, so if I would do that thing you said I must implement ray picking in my object editor to set whether object is wall or floor. But imagine something like barrel, it’s top must be as floor type and sides as wall but ray picking could pick only the whole barrel, or I must pick all triangles individually and then set whether they are walls or floors. This thing looks messy.

It sounds messy.

You either have to deal with the approach you’re taking and do the complicated determination of whether something is a wall or a floor, or you can simplify your approach and determine ahead of time whether and object is a wall or a floor. Keep in mind that a barrel might be comprised of multiple surfaces: two walls and a floor, for example.

Basically the issue is you are checking collision around the person entirely and then setting falling to 0 , to ensure this doesnt happen split it up so you check upward downward left and right collsions seperately , you can then use the booleans of these to check if they are falling or not. hope this helps.