Im making a traffic simulator, when i drive my car (which i dont use rigidbody physics to move) and go really fast and try to collide with the npc car in-front of me (i have a box collider thats a trigger) my BoxCast extends a bit forward right when im behind the npc car and prevents me from hitting it. Is this normal behaviour? If it is can i turn it off.
I have Screenshots:
This is when i tried to collide with the npc car i was going really fast, You can see how boxcast extented meter right when i tried to hit npc, in a normal scenario when im going fast it doesnt go that far in front
private void RaycastForCollision()
{
RaycastHit hit;
Vector3 rayOrigin = transform.position + new Vector3(0, 0.5f, 0); // Start ray slightly above the center of the car to avoid ground collisions
Vector3 rayDirection = transform.forward;
Vector3 boxCenter = transform.position+new Vector3(0,boxCenterAdjustment,0);// + transform.forward * (carHeight / 2);
Vector3 boxHalfExtents = new Vector3(transform.localScale.x+adjustHitboxWidth, carHeight / 2, transform.localScale.z *2+adjustHitboxLength);
Quaternion boxOrientation = transform.rotation;
Vector3 castDirection = transform.forward;
moveDistance = Mathf.Max((currentSpeed * Time.deltaTime), minmovedistance); // Ensure minimum distance to avoid zero-distance cast
Debug.DrawRay(boxCenter, castDirection * rayDistance, Color.red);
//canmove=!Physics.BoxCast(boxCenter, boxHalfExtents, castDirection, boxOrientation,moveDistance);
bool forwardHit = Physics.BoxCast(boxCenter, boxHalfExtents, transform.forward, out RaycastHit forwardHitInfo, boxOrientation, moveDistance);
//canmove = !(forwardHit || leftHit || rightHit || upHit||backwardHit );
canmove = !(forwardHit);
if (forwardHit)
{
//HandleCollision(forwardHitInfo.normal);
}
Box.DrawBoxCastBox(boxCenter, boxHalfExtents, boxOrientation, castDirection, moveDistance, Color.red);
}