"Gravity" in the terrain example?

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
NexusInteractive
Posts: 33
Joined: Sun Jun 26, 2005 4:41 pm

"Gravity" in the terrain example?

Post by NexusInteractive »

Hello. I'm using the terrain example to try out different things for irrlicht and stuff, but I don't like how the camera just "flys" around. I would like the player to stay on the ground instead of going wherever the cursor points.

I'm really new to Irrlicht, so could you please explain where the codes go in the example and such?

Thanks!
bakkdoor
Posts: 49
Joined: Fri May 07, 2004 4:31 pm
Location: home

Post by bakkdoor »

check out the quake3 map example (i think its example 3) at the tutorials..it is used there too.
NexusInteractive
Posts: 33
Joined: Sun Jun 26, 2005 4:41 pm

Post by NexusInteractive »

I'm really new to Irrlicht and C++ so i have no idea what does what in that code... (and i think it's tut #6 that has the gravity)
bakkdoor
Posts: 49
Joined: Fri May 07, 2004 4:31 pm
Location: home

Post by bakkdoor »

try something like this:

Code: Select all

// set the camera scenenode...
scene::ICameraSceneNode* camera;

camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(10,100,10));


// load the "gravity"-animator...
scene::ISceneNodeAnimator* animator = smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(30,50,30),
		core::vector3df(0,-100,0), // 100.0f, 
		core::vector3df(0,50,0));

camera->addAnimator(animator); // <- gravity (!!)
animator->drop();
hope that helps..
NexusInteractive
Posts: 33
Joined: Sun Jun 26, 2005 4:41 pm

Post by NexusInteractive »

Well, I tried and nothing happens. I don't get any errors and there isn't any gravity... Here's what I have:

Code: Select all

// add camera
	scene::ICameraSceneNode* camera = 
		smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);

	camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
	camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
	camera->setFarValue(12000.0f);

	// load the "gravity"-animator...
	scene::ISceneNodeAnimator* animator = smgr->createCollisionResponseAnimator(
      selector, camera, core::vector3df(30,50,30),
      core::vector3df(0,-100,0), // 100.0f,
      core::vector3df(0,50,0));

      camera->addAnimator(animator); // <- gravity (!!)
      animator->drop();
Any ideas?
NexusInteractive
Posts: 33
Joined: Sun Jun 26, 2005 4:41 pm

Post by NexusInteractive »

Okay, I put it in the wrong place. It works okay now. I also had to change core::vector3df(0,50,0)); to core::vector3df(0,100,0)); becuase the camera kept bouncing up and down. But now, when I go up a hill, the camera bounces slightly and i slide back down. Would it be possible to make it not do that?
Computer Specs:
AMD Duron 1.8 GHZ + 256 MB RAM + ATI Radeon 7000 Series + 20gig HDD + PCChips K7 MotherBoard
Post Reply