Change the parameters of a collisionAnimator

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
benjani13
Posts: 25
Joined: Sat Aug 07, 2010 8:12 pm

Change the parameters of a collisionAnimator

Post by benjani13 »

Hi, I have a CollisionResponseAnimator added to the player mesh who work perfectly. I'd like to change the animator parameters in a function of my eventReceiver but that doesn't work.

I create my animator like that:

Code: Select all

   scene::ISceneNodeAnimatorCollisionResponse* anim;
	if (selector)
	{
		anim = smgr->createCollisionResponseAnimator(selector, playerNode, 
													core::vector3df(19, 40.0f, 9.25f),
													core::vector3df(0, -10, 0), 
													core::vector3df(0, 18, -1));
		playerNode->addAnimator(anim);
	}
I send the animator to my class "MyEventReceiver" in its constructor:

Code: Select all

	MyEventReceiver eventReceiver(device, anim);
	device->setEventReceiver(&eventReceiver);
But in my class MyEventReceiver, when I modify an animator parameter, it doesn't work anymore.

So, I'd like to know how to modify an animator parameter during the program, in my class.
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Post by Iyad »

What did you change im your animator? Passing your animator pointer to another class should not be the problem. Your problem is surely in the changes you made in the collision response animator, post them if you still need help...
#include <Iyad.h>
benjani13
Posts: 25
Joined: Sat Aug 07, 2010 8:12 pm

Post by benjani13 »

If modify whatever parameter of the collision animator in a function of my class like this:

Code: Select all

m_playerCollisionAnimator->setGravity(core::vector3df(0, -10, 0));
There's no more collision, the collision animator doesn't work anymore.

Exactely, this happen when the modification is in during the rendering, look:
This work:

Code: Select all

	
anim->setGravity(core::vector3df(0, -10, 0)); //The modification 
while(device->run())
	{
		if(device->isWindowActive())
		{
			driver->beginScene(true, true, 0);
			smgr->drawAll();
			gui->drawAll();

			time = (f32)device->getTimer()->getTime();
			
			eventReceiver.updateNodePositons(time - lastTime);
			eventReceiver.replaceCamera();
			

			if(time - lastTime < MIN_FRAME_TIME)
			{
				device->sleep((u32)(MIN_FRAME_TIME - (time - lastTime)));
			}
			else
			{
				lastTime = time;
			}

			driver->endScene();
		}
		else
		{
			device->sleep(500);
		}
	}
This doesn't work:

Code: Select all

	
while(device->run())
	{
		if(device->isWindowActive())
		{
         anim->setGravity(core::vector3df(0, -10, 0)); //The modification 
			driver->beginScene(true, true, 0);
			smgr->drawAll();
			gui->drawAll();

			time = (f32)device->getTimer()->getTime();
			
			eventReceiver.updateNodePositons(time - lastTime);
			eventReceiver.replaceCamera();
			

			if(time - lastTime < MIN_FRAME_TIME)
			{
				device->sleep((u32)(MIN_FRAME_TIME - (time - lastTime)));
			}
			else
			{
				lastTime = time;
			}

			driver->endScene();
		}
		else
		{
			device->sleep(500);
		}
	}
Post Reply