Separating axes theorem implementation only working along X and Z axis(infinitely extending colliders along the Y axis)

Started by
2 comments, last by jakob_tadej8 5 months, 1 week ago

So pretty much what the title is. My collision response and detection seem to be working fine apart from a bit of jank and the fact that all colliders extend infinitely along the Z axis and I can never reach the end, but on the X and Z they work as expected. I am completely dumbfounded on this one so thanks in advance!

CODE

Advertisement
	//Resolving collision
    pos -= mtvAxis * overlap;
 
vel.y = 0;

What is "vel" on line 94? Did you edit the bug out of the code sample?

Omae Wa Mou Shindeiru

@LorenzoGatti I simply apply velocity to pos with vel every frame (with dt of course), otherwise since I am just testing collisions so I reset the falling speed so I dont have to bother with gravity while testing collisions. Below I am attaching the 2 functions I call just in case theyre relevant

void Body::ApplyGravity(){
if(isGrounded){
return;
}
vel.y += GRAVITY * deltaTime;

if(vel.y < terminalV){
vel.y = terminalV;
}
}
void Body::Update(){
if(isStatic){
return;
}


ApplyGravity();
pos += vel * deltaTime;


UpdateVertices();



//do it in a global func or smthn
isGrounded = false;
}

This topic is closed to new replies.

Advertisement