Character and Body Collision Callback?

Rope

06-04-2008 16:52:37

Well back in my FPS game,...

I've implemented a NxOgre::Character which we are controlling.

I also implemented the enemies as Character's ,too. I don't know if it is true or not. However , I'm stuck on somewhere while implementing like this.

Our character throws "man.mesh" when mouse_right_clicked.

Then, I want to do something when the "man.mesh"(NxOgre::Body) hits to the enemies(NxOgre::Character) .

I have set the groups of these two and implemented a Callback.

class myCallback : public GroupCallback::InheritedCallback {

public:

void onStartTouch(Actor* a, Actor* b) {

a->setGlobalPosition(Vector3(1500,200,100));

//b->setGlobalPosition(Vector3(1500,200,100));



}


};


here, the program enters the onStartTouch function. Because I see that
the body, i mean the "man.mesh" dissapears from the screen and moves to the position I gave.

But, when I add the commented line which I hoped to move the enemy character; the program throws an exception.

I think it's because Character has NxActor, not Actor? ... Maybe not.
Somehow, b is null.


What should I do? Can I implement CharacterHitReport to many Characters? I mean all of the enemies...

Or, how should I implement the enemies to handle them like Character class, with a capsule and vectorMovements... Maybe making them body,too but with different params?

Thanks a lot!

Rope

07-04-2008 11:26:48

no answers? :roll:

Well, I kept working on what I am doing and improved it a little bit.


I wrote an Enemy class which has a name variable in it. And an EnemyManager to return the enemy I wanted when needed...


I have written a contact reporter for catching BULLET(man.mesh,Body) and the ENEMIES(Character) .


Then...

class BattleContactReporter : public NxUserContactReport
{
public:
virtual void onContactNotify(NxContactPair& _pair, NxU32 _events);
private:


};



and...

void BattleContactReporter::onContactNotify(NxContactPair& _pair, NxU32 _events)
{


if (_events & NX_NOTIFY_ON_START_TOUCH){

_cprintf(_pair.actors[0]->getName());




if(_pair.actors[1]->getLinearVelocity().x > 600 || _pair.actors[1]->getLinearVelocity().y > 600 || _pair.actors[1]->getLinearVelocity().z > 600){



FPSGame::getInstance()->enemyTest.getEnemy(_pair.actors[0]->getName())->decreaseEnergy(50);

}






}

}


This really works well. However, ContactReporter cannot handle "CharacterToCharacter" collisions. I don't know what can handle them?

But I must!

I also tried the CharacterHitReport , but it didn't seem to work for "CharacterToCharacter", too.

What can I do?
Maybe writing a hack code like positioning a invisible body on enemies position on every frame? Ihgh... disgusting solution!

Please help me! Thanks.

LFMS

09-06-2008 14:34:27

no answers? :roll:



Rope did u have more advances????

im tring to implement CharacterHitReport in this weekend but i don´t advance so much ...