Collision Help

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
GundamO
Posts: 9
Joined: Thu Nov 11, 2010 11:34 am

Collision Help

Post by GundamO »

Hi Guys,

I am attemping to create a Platforming game, i am using a class structure to load all of my objects into my scene.

i am trying to use a metatriangle selector to deal with the collision between my player model, terrain and platforms. My problem arises when i add my terrain triangle selector to the meta list, when i add the terrain my model's movement messes up, it just stays in one place and jitters about, when i remove the terrain from the list my player model will then end up sinking underneath the terrain to get around the platform (even when using the terrain get height function).

Code: Select all

//meta list
scene::IMetaTriangleSelector* anim2 = smgr->createMetaTriangleSelector();
		   anim2->addTriangleSelector(land->selector);
		   land->selector->drop();
		   anim2->addTriangleSelector(box1->selector);
	       box1->selector->drop();
		   anim2->addTriangleSelector(box2->selector);
		   box2->selector->drop();
	       anim2->addTriangleSelector(box3->selector);
		   box3->selector->drop();
	       anim2->addTriangleSelector(box4->selector);
		   box4->selector->drop();
	       anim2->addTriangleSelector(box5->selector);
		   box5->selector->drop();
	       anim2->addTriangleSelector(box6->selector);
		   box6->selector->drop();

	   ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
		   anim2,turtle->node,core::vector3df(30,30,30),
		   core::vector3df(0,0,0),
		   core::vector3df(0,0,0),0.0005f);
	   anim2->drop();
	   turtle->node->addAnimator(anim);
	   anim->drop();

(extract to deal with movement)
Tposition.Y = land->terrain->getHeight(Tposition.X,Tposition.Z);//set the turtle ypos to terrain height
			turtle->node->setPosition(Tposition);
			turtle->node->setRotation(core::vector3df(0,angle,0));

if(receiver.IsKeyDown(irr::KEY_KEY_W))
			{
				Tposition.X += MOVEMENT_SPEED * frameDeltaTime * cos(DEG2RAD(angle-90));
				Tposition.Z -= MOVEMENT_SPEED * frameDeltaTime * sin(DEG2RAD(angle-90));
				
			
			}
			if(receiver.IsKeyDown(irr::KEY_KEY_S))
			{
				Tposition.X -= MOVEMENT_SPEED * frameDeltaTime * cos(DEG2RAD(angle-90));
				Tposition.Z += MOVEMENT_SPEED * frameDeltaTime * sin(DEG2RAD(angle-90));
				
				
			}
			if(receiver.IsKeyDown(irr::KEY_KEY_A))
			{
				angle-=1;
				
			}
			if(receiver.IsKeyDown(irr::KEY_KEY_D))
			{
				angle+=1;
				
			}
Thanks in advance for any help
Post Reply