Character movement on uneven terrain

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
theOneAwaited
Posts: 12
Joined: Fri Aug 14, 2009 10:03 am
Location: Netherlands

Character movement on uneven terrain

Post by theOneAwaited »

Hey guys,
I am brand new to Irrlicht and have gone through these forums like crazy to learn all the examples. I have managed to load terrain, a character, third-person camera, and make my character walk to a point that I select on the terrain.

Now my current problem is that my character does not stay flat on uneven terrain when he is walking. For example, if he starts on a hill, he stays in the air while walking to the next location. He still moves with the terrain, but not even with the ground.

I was wondering how to 'properly' adjust the character's Y position so that he stays flat on the ground while walking....without implementing a full-blown physics system. Do I need to shoot a ray from his position, into the terrain, check the distance and adjust it?
Or does Irrlicht handle this and I am missing it?

If there are any other links in this forum that address this question, please post them so I can figure it out :lol: Thanks in advance!
yamashi
Posts: 82
Joined: Sat Jan 03, 2009 4:53 am

Post by yamashi »

Using the getHeight function of the terrain you should be able to do it.
But using a physic engine is always a good thing, you might need it later.

Code: Select all

vector3df charPos = character->getPosition();
charPos.Y = terrain->getHeight(charPos.X,charPos.Z);
character->setPosition(charPos);
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Aye if you use a physics engine then they provide character controllers which make all this stuff easy peasy! Having said that if your requirements are fairly simple, i.e. just having the character follow the terrain then that's certainly something you could take care of yourself.

So what are your plans with this project? Reckon you might need a physics engine? Want objects falling around and being all interactive etc? Or is it a simpler project where objects won't need to move around in such complicated manners?
Image Image Image
theOneAwaited
Posts: 12
Joined: Fri Aug 14, 2009 10:03 am
Location: Netherlands

Post by theOneAwaited »

I have two projects I'm working on actually. One is a top-down shooter, so all I need is basic movement and collision.

But I also have another project that is more like an RPG, with characters moving around on uneven terrain. I know I need a physics engine for that one, but I guess I'm trying to learn basic Irrlicht functions first, before I start learning wrappers that manipulate them.

And unfortunately, I don't have an Nvidia graphics card, so some physX components are running on software rendering....aka SLOW.

So I am trying to use ther terrain->getHeight function and the character is moving a little weird...like he is colliding more often with the terrain and getting stuck...I'm gonna try fiddling with the variables and see what happens![/quote]
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Just stick to the simple project completely until you've finished it and learn loads about how irrlicht works. You really don't want to be developing an RPG at the same time as learning a new bit of software... You'll make a lot of mistakes on your first project and learn a lot in the process so then you'll have a much stronger foundation for starting the RPG :)

You don't need a Nvidia graphics card to get decent performance out of Physx, you just need to be sensible about how you use it and optimise your objects!
Image Image Image
psychophoniac
Posts: 101
Joined: Wed Dec 03, 2008 5:33 pm
Location: ger

Post by psychophoniac »

i used the collision animator at the beginning, works fine so far.
later i made a modified version where you can add specific actions wich happen if you collide or sth.
for "walking" i used the fly straight animator, i think you need to first add the collision and then the fly straight animator and you node will not walk the direct way, but will fly over hills to its target. you should mind that the points you send your node to should be located above the terrain, because else the node will start to flicker around, because the flystraight and the collision animator are like enemies, wich both want to modify the nodes position, wich is funny to watch but not usefull ^^
i love skateboarding!
Post Reply