Gravitation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
i245
Posts: 8
Joined: Sun May 20, 2007 5:16 pm

Gravitation

Post by i245 »

Hi all.
This is my init code:

Code: Select all

mNode->removeAnimators();
ISceneNodeAnimator*  triscolanim=gSceneManager->createCollisionResponseAnimator(
selector,mNode,vector3df(30,24,30),
vector3df(0,-3,0),
vector3df(0.f,-0.f,0.f));
mNode->addAnimator(triscolanim);
triscolanim->drop();
...and in main loop:

Code: Select all

	if(gKeys[KEY_UP])
	{
		vector3df pos = gCamera.getCamera()->getPosition();
		vector3df view = mNode->getPosition();

		vector3df v = pos - view;
		v.Y = 0;
		v = v.normalize();

		v.X *= n;
		v.Z *= n;
 
		mNode->setPosition(mNode->getPosition() - v);
	}
My problem: while i was pressing up key, my model was slow falling if he has nothing under. What i do wrong?

PS: sory for my bad english
cyberion
Posts: 30
Joined: Tue Oct 23, 2007 5:53 pm

Post by cyberion »

Try to change your gravity from

Code: Select all

vector3df(0,-3,0),
to

Code: Select all

vector3df(0,-10,0),
i245
Posts: 8
Joined: Sun May 20, 2007 5:16 pm

Post by i245 »

It's acceleration problem, i guess.
alaNegru
Posts: 5
Joined: Sun Mar 16, 2008 12:16 pm

Post by alaNegru »

hey i have the same problem.

First of all to modify gravity does the job but then the falling speed is too big when i am not moving and it makes stair climbing very difficult. So this isn't much of an option...

I thought of increasing the gravity when i am in mid air and decrease it back whem i hit the ground. Is there a way to messure the distance from my char node to the ground?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can use the collision animator's function isFalling() which tells you if the node that uses the animator is falling but it doesn't work particularly well to be honest... At least not in the simple way i used it, i got times when i was falling after reaching the top of some steps, i guess that's because i sort of ran up the steps and left the ground for a split second at the top and so fell back down to the ground only a few units but still counted as falling. If i checked how far it had fallen then i could probably have got rid of that problem...
Image Image Image
alaNegru
Posts: 5
Joined: Sun Mar 16, 2008 12:16 pm

Post by alaNegru »

yep... isFalling is really bugged. Still looking for a solution :D
alaNegru
Posts: 5
Joined: Sun Mar 16, 2008 12:16 pm

Post by alaNegru »

ok... isn't anyone here who made and fps, or 3rd person game and who can help me out with this?

I tried to figure out what makes it behave that way but no results. How it the event receiver made and why is my char not influenced by gravity when the receiver is taking input?
Post Reply