Kinematic triggers?

Rebeh

27-01-2008 14:53:28

Hi, I'm current trying trying to add some game functions using triggers. The triggers must be movable and I also need to be able to turn on/off it's collision. However, I faced some problems.

1) Kinematic triggers crashes the application whenever i tries call a functions form Trigger that modifies the Actor in some way or the other. Non-static triggers gives the same result.

2) I could move static triggers around but it generates errors form NxOgre. Also, some times the callback does not regesiter with the trigger. I suspect it has got to do with the errors.

I'm currently also looking at replacing trigger with intersections. Would it be a better implementation for functions that I mentioned?

betajaen

27-01-2008 15:06:44

1) Kinematic triggers crashes the application whenever i tries call a functions form Trigger that modifies the Actor in some way or the other. Non-static triggers gives the same result.


That's weird. Can you show me some examples?

As for your intersection question; You could do it that way, but I've always thought intersections are best used with handling explosion's, quick check of actors in a certain area, etc. Besides if you used intersections to replace triggers, you would have to keep a list of actors somewhere and compare it each time you used it; more or less exactly what the triggers does. ;)

Rebeh

27-01-2008 15:20:52


// Constructor for a Trap Hitbox class
CSwordHitbox::CTrapHitbox(unsigned int playerID_, Ogre::Vector3 pos_, NxOgre::Scene* scene_, float currentTime_, float duration_, float delay_ = 0.0f)
{
mName = makename("TrapHit", mTrapHitboxCount);
mTrigger = 0;

mStartTime = currentTime_;
mDuration = duration_ <= 0 ? 0.1 : duration_;
mDelay = delay_ <= 0 ? 0 : delay_;

// Create the trigger if theres no delay
if (mDelay == 0) {
mTrigger = scene_->createTrigger(mName, new NxOgre::CubeShape(10,10,10), pos_, "kinematic: yes");
mTrigger->setCallback(CHitboxCharacterCallback::Singleton());
} else {
mScene = scene_;
mPosition = pos_;
}

mPlayer = playerID_;

mTrapHitboxCount++;
}

// Logic loop
void CTrapHitbox::HitboxLogic(float timeElapsed_, float timeTotal_) {
if (mTrigger == 0) {
if (timeTotal_ >= mStartTime + mDelay) {
// Create the trigger if the delay in activating is up
activate();
}
} else {
if (timeTotal_ >= (mStartTime + mDelay + mDuration)) {
// turn off the trigger once the trap duration is up
mTrigger->disable(); // this line crashes
markdead();
}
}
};


There's another variant of the trap the moves around the place, but it also crashes when i call mTrigger->setGlobalPosition(). In both cases, mActor form trigger is a null pointer.

betajaen

27-01-2008 15:25:25

I wouldn't use Actor::disable, and it's probably not what you think it is, but if you're getting a null mActor then PhysX could not create the trigger. I would try out your code in my copy of cake (in bleeding) but I've changed the error system and I'm getting ~100 compile errors at the moment that I have to sort through. :P

Rebeh

27-01-2008 15:31:48

Haha. Many thanks. I will keep trying on my side too meanwhile.