Forbitten areas based of height

Dibalo

07-07-2007 20:36:28

Ok. I have thought this a moment and I don´t have any smart solutions to this problem so I ask this from you. I have a water. Its height is constant everywhere but because my terrain´s height variations there are many little areas covered by water. Now I need to stop my player going into the water. Here is my problem. Is there some kind of way to stop NxOgre::Character based on height (this time water)? I´m very thankful if you invited something useful. :shock:

EDIT: I use NxOgre .9.

betajaen

07-07-2007 20:45:20

Yes. But it isn't invented yet; Character Triggers.

You could do it yourself. Create a Actor with a Shape over/above the water. Set it to a group that none of the other Actors collide with.

Use a Custom CharacterHitReporter, and set it to hit when the Character hits an Actor with that Group.

Dibalo

07-07-2007 21:49:19

You mean that first i create a static shape (for example box or some kind of plane) to my game to same level as water? Then I make a new group and set that actor to that group? When my character hits that plane, my custom hitreporter tells that character is collided with my water plane? And then? Am I able to stop character moving towards water in that HitReporter? How does this basically works? This is new for me... :?

betajaen

07-07-2007 22:05:40

Yep.

To clarify. The Actor's can be static or kinematic doesn't matter. You create two Groups; an ActorGroup "WaterGroup" for collision with the Character, and a ShapeGroup "WaterShapeGroup" for collision with other Shapes in Actors. Turn off (let the Actors pass through) collisions for every group you have, including the "WaterShapeGroup".

Like you said then your HitReporter controls collisions with other Groups. You won't need to control all of the collisions, the others will do it for you, the code just deals with that group only.

The follow is the code for above, it's very rough and some bits are missing. But I think you'll get the idea.



ActorGroup* mWaterGroup = mScene->createActorGroup("Water");
ShapeGroup* mShapeWaterGroup = mScene->createShapeGroup("WaterShape");
mShapeWaterGroup->setCollisionResponse(mScene->getShapeGroup("Default"), CR_No_Collision);

mScene->createActor("Water1", new CubeShape(10,5,10, "group: WaterShape"), Vector3(10,2.5,10), "kinematic: yes, group: Water");

...

class WaterGroupHandler : public NxOgre::CharacterHitReport {

public:

virtual Response onActor(Character*, Actor*, Shape*, ActorGroup*, const NxControllerShapeHit&);

virtual Response onCharacterHit(Character*, Actor*, Shape*, ActorGroup*, const NxControllersHit&);


};

...

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

if (ag == mWaterGroup)
return RS_Push;

return RS_None;
}

...

mWorld->getCharacterController()->addHitReport(new WaterGroupHandler());

Dibalo

08-07-2007 09:48:33

Yes. I got that. Thank you!