Unit movement on 3d terrain?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Unit movement on 3d terrain?

Post by odenter »

First of all my english isn't perfect. :)

I've a Terrain and want to move units on this terrain. But every unit should move the same distance.
How can I do this?

First idea was to have an Grid invisible over my terrain and one unit move from one quad to next quad, like in a 2d, tiled game.
Drawing a 2d grid isn't the problem but a 3d grid (mountains, river).

Any advice for me?
CuteAlien
Admin
Posts: 9691
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I am not exactly sure where you have the problem...

For drawing a terrain you should check the terrain rendering example (example 12).

For placing the units you do usually as you already guessed: You calculate them all as if they would move on a 2d grid. For placing them on the terrain you can adapt the height after those calculations.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

Indeed, a 2D solution can also have the same obstacles where grid locations are water or mountainous terrain.
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Post by odenter »

The problem wasn't to draw a model.
The problem was I thought wrong. :P

Moveing is like in 2d (elapsedTime * something). My problem was moving on/to higher points. Maybe I want to have hills and mountains. A hill should be passable a mountain not. So how to i code this? Now I knew vectors are my friends. :)
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

Well, i think the more accurate solution would be to split your terrain into tiles (browse to the forums, there are solutions for tiled terrains already) and make your characters walk the ammount of tiles you want (making tiles into units of movement, sort of).
You can also have a 3d line, and make your character walk from the begining to the end of it.
Another cool solution is timed movement, you make your character walk in some constant period of time at variable speeds or vice-versa.
And also (as always, there is the hard way to do it), you can project some (arrow) mesh into your terrain and make the characters walk the projected lenght of the arrow mesh....
I would pick the timed movement idea, its accurate enought and stylish 8)
Post Reply