I believe I saw this somewhere else but I'm not sure if there was ever a resolution. What I've noticed is that when a csColliderActor collides with another object, other than the world, it collides with the center of the object; not with the outer edges of the object.
Part 1 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I use:
// If the collider get hit mesh array has objects in it
if(collider_hero.GetHitMeshes().GetSize()>0)
{
csRef<iMeshWrapper> i=collider_hero.GetHitMeshes().GetIterator().Next();
csRef <iObject> object = i->QueryObject();
To find what I've hit, so say I want to hit a large bubble (sphere), I use:
// Check for inventory items
if(!items.Contains(object->GetName ()))
{
items.Delete(object->GetName ());
engine->RemoveObject(object);
inventory.Push(object->GetName ());
}
While this works for smaller objects, I imagine because the objects size and center are closely oriented; it does not work for larger objects. I will get the collision I want if I walk into the object, and jump upwards until I reach the objects center.
Part 2 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I see a similar problem when I have a project collide with an enemy. I want there to be an explosion animation on the site of impact. The collision works, but the explosion is always a few marks above whatever is hit:
// Do a beam to check if we hit something
csSectorHitBeamResult rc = lasersector->HitBeamPortals (
laserstart, WeaponMesh->GetMovable()->GetFullPosition());
// If we hit a mesh...
if (rc.mesh)
{
// Loop to only animate the detonation once, otherwise multiple explosions are drawn
if (animate != 1)
{
// Start an explosion at the site of the collision
StartExplosion(rc.mesh->GetMovable()->GetSectors ()->Get (0),
rc.isect);
// Remove our weapon mesh (if desired)
engine->RemoveObject(WeaponMesh);
// Set the animation flag so that the loop is exited
animate = 1;
}
Not really sure what I'm asking. I guess I want be able to collide with a large object, at it's edge and be able to illicit a reaction of some sort. Should I be doing per-polygon collision detection or something other than what I am above?
Thanks!