Character Controll

M@gg!

15-08-2006 17:25:02

I've now implemented the character and it seem to work so far :)

Good job Betajaen :!:

But as always I'd like to use some extras like setting the movement speed.

At the moment I'm cheating a litle bit, because I've been editing your code to slow down the movement. But, isn't there an other way to do this?

betajaen

15-08-2006 17:33:02

Not at the moment, but there will be a character speed variable for walking, falling, swimming and so on.

M@gg!

15-08-2006 17:47:42

:cry: :cry: :cry:

Ok, then I'll have to tweak your code a litle bit more.

*makes fun :wink: *

M@gg!

17-08-2006 12:36:23

I'm a litle confused. How do I use a contact reporter with my character?

For contact reporters I do need two bodys, but a character seems to have no body, or does it?

I want to start a specific action when my char is hit!

betajaen

17-08-2006 12:54:03

Nope it doesn't have an body, but it's got an actor. Which with a bit of fiddling you might be able to pull it off.

I haven't got that far in the controller to think about those sort of things yet or even prototype them.

M@gg!

17-08-2006 13:43:13

And what's about the character "onShapeHit()" function?

Is there a way to use this?

betajaen

17-08-2006 14:53:35

That is to do with when a character hits an NxActor and what to do. i.e. Move the Actor if it is dynamic or do nothing if it is not.

It's already implemented in the controller anyway.

M@gg!

17-08-2006 17:19:40

:cry: :cry: :cry:

Ok, then I'll have to tweak your code a litle bit much more.

*makes fun :wink: *


:cry: :cry: :cry:

M@gg!

19-08-2006 12:10:44

Now I have started to use PhysX for compenstation of the missing contact report.

But some how I can't set or check the groups right.

First I have defined a new class:

#ifndef __CONTACT_REPORTER_H_
#define __CONTACT_REPORTER_H_

#include <nxOgre.h>
#include <Ogre.h>

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


};


---------

#include "battle_contact_reporter.h"

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

if ((_pair.actors[0]->getGroup() == 3) && (_pair.actors[1]->getShapes()[0]->getGroup() == 4)){
Ogre::LogManager::getSingleton().logMessage("Actor 0 = Player");
}
else if ((_pair.actors[0]->getGroup() == 4) && (_pair.actors[1]->getGroup() == 3)){
Ogre::LogManager::getSingleton().logMessage("Actor 1 = Player");
}
else{
Ogre::LogManager::getSingleton().logMessage("Actor 0 Group:" + Ogre::StringConverter::toString(_pair.actors[0]->getGroup()));
Ogre::LogManager::getSingleton().logMessage("Actor 1 Group:" + Ogre::StringConverter::toString(_pair.actors[1]->getGroup()));
}
}
}


Now I made an instance of it and pass it to the PhysX Scene Manager:

scene is of Type nxOgre::scene

mBattleContactReporter = new BattleContactReporter();

scene->mScene->setUserContactReport(mBattleContactReporter);
scene->mScene->setActorGroupPairFlags(1,2,NX_NOTIFY_ON_START_TOUCH);


In a nother part of my code I create a CubeShape for testing and set a group:

nxOgre::body *mBdyTest = mScene->createBody("testbox","cube.mesh", new nxOgre::cubeShape(Ogre::Vector3(0.5,0.5,0.5)), 200,
Ogre::Vector3(6,30,-4));
mBdyTest->mNode->scale(Ogre::Vector3(0.002,0.004,0.002));

//**
//Set Collision Group
//**
mBdyTest->mActor->setGroup(5);


After this I create my projectiles nearly the same way:


mBdyBody = mNxSceneManager->createBody(mName, "sphere.mesh",new nxOgre::sphereShape(_size * 0.4), _weight, _position);

mBdyBody->setGlobalOrientation(mDirection);
mEntBody = mSceneManager->getEntity(mName);
mNodBody = mEntBody->getParentNode();
mNodBody->scale(Ogre::Vector3(0.0003,0.0003,0.0003));


//**
//Set Collision Group
//**

mBdyBody->mActor->setGroup(4);


When I'm now shooting at the TestCube, there is a log entry, but it says:
Actor 0 Group:2
Actor 1 Group:4

Beneath the Cube there is a static castle which is hit too, because the projectile bumps of. So the entry seems to be from this contact.
nxOgre::body *bdyCastle = mScene->createStaticBody(_name, _mesh, new nxOgre::meshShape(_mesh, mScene), Ogre::Vector3::ZERO);

Changing the TestCube to static didn't help.

I'd be happy if somebody can help me.

M@gg!

19-08-2006 20:15:22

I found out why it didn't work.

I forgot to set:

scene->mScene->setActorGroupPairFlags(group1, group2, NX_NOTIFY_ON_START_TOUCH);

For each of the wanted collision reports.

In addition there are a lot of minor bugs in the code above.

Does anybody know, why I can't generate a contact report between two characters the same way?

betajaen

19-08-2006 23:23:35

Hang on a minute, contacts between two character controllers?

Can't you just fill in this part of the code?

NxControllerAction character::onControllerHit(const NxControllersHit& hit) {
...
}

M@gg!

20-08-2006 09:47:39

What functionality exactly do you intend?

betajaen

20-08-2006 09:53:39

Well it seems, that people are using the character controller in different ways than I though.

As well as simple body collision physics, I'll have to implement a "listener" system so developers can watch when say a specific or larger body is touching the player.

M@gg!

20-08-2006 12:47:59

At the moment there are two things preventing me to write this.

First is time, the second is, that my knowledge about PhysX is still 1 week young. With NxOgre it's after all 1 1/2 week :D

My goal at the moment is to get the game ready and document it so that it hits the deadline next friday. After this I plan to rewrite it completely and work directly with PhysX.

So it'll take at least two weeks till I know enough about PhysX to do it in a good way. But then I'll try to help you if you then are still interested in.

betajaen

20-08-2006 13:20:54

Well it shouldn't be to hard to implement the listener system yourself.

All you need is a listener class which then you sub-class, then tell your character to run those listener functions when it hits something.

More or less you could take out the trigger code and put into the character, it's the same setup really.