Collisions between actors and characters not always working

NeilInglis

13-04-2008 17:53:27

I am currently making a CharacterHitReport for colliding with actors. I have a class that contains 2 characters, a body and a head. The body moves around using setNextRawMovementDirection() and set Direction and the head follows using setPosition(). I have tried setting all the parameters the same on the two, even the mesh. I cannot see any other differences between the two characters.

In my CharacterHitReport when i test if (c == head) it will find a collision and act on it, but it never acts if (c == body). I have even tried just testing the actors they are colliding into, not testing what character is hitting it, and it still only acts when the head comes in contact. Whenever the body is hitting the object, the object just goes flying away. Does anybody know of something I might be doing wrong, or a bug that I am encountering?

Below is a sample of my onActor hit report function and what is happening for each if.


CharacterHitReport::Response BirdCharacterHitReport::onActor(Character* c, Actor* a, Shape*, ActorGroup*, const NxControllerShapeHit& h) {

if (theBird != NULL)
{
if (c == theBird->getBody())
{
//no reaction when body touchs anything
}
if (c == theBird->getHead())
{
//reaction when head touches an actor
}
if (a->getGroup()->getName().compare("Item")==0 )
{
//reaction when head touches but not when body touches
}

if (a->getGroup()->getName().compare("Enemy")==0)
{
//reaction when head touches but not when body touches

}
}

return RS_None;
}


Thank you for your help

NeilInglis

17-04-2008 22:22:25

Nevermind, i found the problem. To notice when the collision was happening, I just set the body back to it's start position. For some reason when you try to set the position of the character involved in the collision in the hit report, it doesn't work. Instead i just set a flag, then on every frame, if that flag is set, it would put the character back to it's start position and reset the flag. It started working when I did this.