i'm trying to write my own character controller using convex cast. i cast player collision (cylinder) down to see if it hits the ground and store it in m_bInContact variable. here's the code (executed every frame):
- Code: Select all
m_bInContact = false;
NewtonWorldConvexCastReturnInfo info[16];
matrix m;
NewtonBodyGetMatrix (getBody()->m_pNewtonBody, m);
vec3 target = m.getPos();
vec3 origin = target;
origin.y += 0.01;
m.setPos(origin);
target.y -= 0.01;
float param;
int result = NewtonWorldConvexCast(gPhys.getWorld(), m, target, NewtonBodyGetCollision(getBody()->m_pNewtonBody), ¶m, getBody()->m_pNewtonBody, ConvexCastCallback, info, 16, 0);
if (result != 0)
m_bInContact = true;
it works absolutely ok with collision tree, but for dynamic bodies it looks unpredictable for me. for example, this body (made as convex hull) is being detected by the convex cast:
but if i scale down vertices of the same collision it is not detected:
player collision size is R=0,4064 H=1,778.
is there something i doing wrong?