using the character's actor

DeFT 2K6

19-08-2006 23:25:21

can I apply forces to the actor of a character? I'm trying to make the character jump.

ie. something like:

mChar->mController->getActor()->addForce(NxTools::convert(Vector3(0,100,0)));


where mChar is a character?

Thx, ciao.

M@gg!

20-08-2006 00:28:39

Sorry, but this way is not working. Perhaps Betajaen knows an other posibility.

By the way, the actor you can get more easily with:

mChar->mActor

[edit:] If you'll take a briefly look in the "nxOgre_character.cpp" you'll find an outcommented function named "jump". So it's planed, but not jet implemented.

DeFT 2K6

20-08-2006 00:36:58

When I tried mChar->mActor it didn't exist, so I had to use the actor from the controller.

Thx.

M@gg!

20-08-2006 00:45:41

When I tried mChar->mActor it didn't exist, so I had to use the actor from the controller.

Thx.


Uuuuups, I forgot. Sorry! It was a litle improvement of myself, because bodys have such a datafield and it was a small thing to add it.

You'll finde the code HERE!

DeFT 2K6

20-08-2006 01:16:07

Cool, thx - this definitely helps, but now I have to figure out how to make the character jump :?
Ciao.

PS - I added a speed for the movement as well, but just did it with an overloaded move method in the character class, so no it has two move methods:


void move(Direction _direction);
void move(Direction _direction, int _speed); // with adjustable speed

betajaen

20-08-2006 09:50:13

Cool, thx - this definitely helps, but now I have to figure out how to make the character jump :?
Ciao.


The old code from Preview 3.0 will help you there, until I sort it all out.

But the trick is once the character has jumped, you need to go in a "no movement except falling in-facing direction mode" so that you can't fly through the air and jump again.

I find combing ray casting and the body meets controller code works wonders.

DeFT 2K6

20-08-2006 19:27:50

Ok, thx I'll take a look at the ray casting stuff and try to combine it with the body meets controller. I'm not sure about the time to fall part as I'm trying to have it so that you can double jump like in UT. I guess that with gravity on and a certain amount of force applied the character should naturally stop going upwards, and at the apex is the only place they can execute the double jump. Is this possible with forces, or do I have to use times?

Thx, ciao.

betajaen

20-08-2006 19:56:36

You could just use a timer and a counter, time how long the duration to the Y vector movement will be, once it's reached 0 and the player presses jump again increase the counter and reset the timer.

Oh, no need to look at preview 3 like I said, the code is commented underneath "#if 0" part of character.cpp & .h

In fact if you really wanted to you could use the old character controller code instead.

DeFT 2K6

20-08-2006 20:08:42

Ok, I will try those suggestions, they sound like good ideas.
Thx, ciao.

M@gg!

20-08-2006 21:23:51

Oh, no need to look at preview 3 like I said, the code is commented underneath "#if 0" part of character.cpp & .h

[edit:] If you'll take a briefly look in the "nxOgre_character.cpp" you'll find an outcommented function named "jump".

:D

betajaen

20-08-2006 22:37:04

How do you pronounce M@gg!?

I always say MOGG! with emphasis on the exclamation mark so like at the end of some jazzy student musical they say "MOGG!!" and there hands are all wavy. Like that.

Hmmm.

[Edit]

Wyx is now telling me via Steam IM that it's Matt Gee-Gee, I'm still not convinced.

M@gg!

21-08-2006 07:20:59

In Magic - The Gathering, a Mogg is a Goblin.

What do they mean with MOGG!?

You are free to speak it like you want it. The aim during the creation of this name was an as far as possible sex neutral name that fits to my real name but does not give it away.
The other thing was that it should inspire the people to think about its pronunciation.

There are people around that call me "Maggi", other say "Magg" or "Mac". I've found one who said like you "Mogg" but doesn't play Magic and did not like to tell me why.

Do you like the name?

betajaen

21-08-2006 09:05:26

Ahh, it's a goblin.

It's still Mogg! to me though. :wink:

DeFT 2K6

23-08-2006 04:55:35

Hi, the jump function just seems to move the character very quickly to the final destination as specified in the mController->move call. Is there any way to make a jump purely based on velocities? I've been trying to use the both the controller's and the character's (not at the same time) actor's setLinearVelocity method, but nothing happens when I call it in my code. I'm aiming for a Mario style jump where the longer you hold down the key the further the jump, but with diminishing gains in height as the velocity is slowly going to zero. Any help on making the jump based on forces and velocities would be much appreciated.

Thx, ciao.

DeFT 2K6

23-08-2006 09:37:36

Nevermind, I just tweaked the nxOgre_character class to contain a jump that works off the principle that d = v*t, and now I can either use the time since last frame in a frame listener or specify a specific duration of the jump. The character appears to rise much more naturally before falling when v = 0.

Thx, ciao.

betajaen

23-08-2006 09:44:27

Oh excellent.

I shall be entering the realm of the character controller today with a personal project of mine, expect many new additions and changes. :D

DeFT 2K6

27-08-2006 00:31:10

Hi, is there a way to orient the capsule controller horizontally? I tried some of the pose functions in Novodex combined with the actor, but could only wind up getting the Ogre sceneNode horizontal, but the controller would always remain vertical. Any help on this would be greatly appreciated.

Thx, ciao.

betajaen

27-08-2006 00:42:46

Sadly no it's meant to be vertical so it doesn't tip over.

The only other way is setting the "blueprint<character>.upDirection" to anything else than NX_Y, but then the character would be walking along the walls rather than the floor.

You could use a box controller though.

DeFT 2K6

27-08-2006 01:09:38

Hmm, I tried setting a different up vector (used UNIT_Z as setUpDirection converts it into NX_Z), but when I clicked debug mode the controller was still vertical. I'll try a box controller, thanks for the suggestion.

It's too bad you can't use a pose with a controller, that would be ideal - my level has no walls as it deals with free-fall

Thx, ciao.

betajaen

27-08-2006 01:20:44

Is it like say a parachute game or something similar, you could use a body.

It has a handy freezeRotation and freezeMovement functions which limit the direction of a body, and you could use forces rather than movement vectors, and gravity will work properly!

DeFT 2K6

27-08-2006 01:36:39

Hehe, great minds... I used an ordinary capsuleShape and body to solve the problem. I add a bit of torque to make the player look like they're slightly left or right oriented to the camera while applying strafing forces. Gives it a feel like the cameraman is right there in the air slightly above the skydiver. Thx for all of your help, ciao.