Best way to create triggers

skumancer

25-11-2008 04:27:55

Hi,

I've tried implementing a "trigger area" using an actor with collision response disabled, but its not working. When I return RS_PassThrough, it still affects the body that I'm hitting.

Any ideas? I basically need to define an area that, when entered by a character, lets me call some functionality.


Thanks a lot,

- Ricardo

Prophet

25-11-2008 10:07:31

Well, there are triggers, you know. Don't ask me how they works, but it's basically a shape that has collisions disabled, but has callbacks whenever something enters it. Sorta.

skumancer

25-11-2008 10:55:38

So I tried creating Triggers and they work (using 0.9).

The problem is that, when I try to access data inside the trigger, it is corrupt. Here is my class:


class FlagTrigger : public NxOgre::TriggerCallback::InheritedCallback
{
public:
FlagTrigger(FlagPoint* flag);

virtual void onEnter(NxOgre::Trigger*, NxOgre::Actor*);
virtual void onLeave(NxOgre::Trigger*, NxOgre::Actor*);
virtual void onInside(NxOgre::Trigger*, NxOgre::Actor*);

virtual void onEnter(NxOgre::Trigger*, NxOgre::Character*);
virtual void onLeave(NxOgre::Trigger*, NxOgre::Character*);
virtual void onInside(NxOgre::Trigger*, NxOgre::Character*);

private:
FlagPoint* mFlagPoint;

};


Now, the problem is that I need to call mFlagPoint->SetTeam() inside onEnter.

When I try to access mFlagPoint, which I passed into the callback's constructor and saved in mFlagPoint, the data in mFlagPoint is not valid.

I don't understand how the data that was previously set (and verified on construction manually) to be good, can be corrupt.

Any ideas?


Thanks,

- Ricardo