I am making my bullet object with ray tracing from the head of bullet object.
Code:
void Hit_Check()
//This function is put in bullet update() function
{
PhysHit hitInfo;
Vec rayStart = matrix().pos;
Vec rayEnd = matrix().pos + matrix.orn().z * 20 * Time.d();
if(
Physics.ray(rayStart, rayEnd, &hitInfo, IndexToFlag(AG_GUN)) ||
Physics.ray(rayStart, rayEnd, &hitInfo, IndexToFlag(AG_TERRAIN))
) {
SoundPlay(UID(xxx)); //Play sound when bullet ray hit something
}
}
There are 3 objects I wanna test.
1: a box object with box collision shape with actor group = AG_TERRAIN
2: a building with static mesh collision shape, actor group = AG_TERRAIN
3:a gun with Convex collision shape, actor group = AG_GUN //my custom group
and this video show how diffirent bullet with its ray interact with above objects.
Drawn red line is the start/end of ray
I realized that are some differences bettween how ray casting check contact
with AG_TERRAIN, collision occured whenever ray "touch" the object, but with AG_GUN, collision occurred when the ray finishes going throuh the object, at the start of the ray, and building with staticmesh collision shape doesn't let the ray touch its structure inside, ray stop right at the bounding box of building
https://www.youtube.com/watch?v=yMs1DRc8TE0
I just want the ray to check collision right at the moment it touch other objects, and how to solve the problem of that building shape
...sorry for my english, i don't know how good my explaination about my problem...