Game Development Community

Making units move independent of terrain

by Ian Roach · in RTS Starter Kit · 10/31/2007 (6:09 pm) · 7 replies

Hi guys, didnt see any past threads on this, but just wondering if anyone knows how to decouple the unit movement from the terrain.

for example having an air unit that moves to a point in space i click, and not tied to the terrain in anyway ?

#1
11/01/2007 (6:17 am)
Ian you should try to create the unit with a transform with a non-default z axis (I havent test this), and the other option that came to my mind is to create a DTS "elevated" from the floor (we see this last case by accident with James when a building he was designing appears "floating" on the mision.
#2
11/01/2007 (6:56 am)
That was no accident! I was just... ah... testing you :D

Ian, the objects I've seen do exactly what Novack has said - the dts is built elevated above the ground plane. It works but the object then literally follows the terrain form and can look rather odd. Think of how the RTS camera behaves as it moves over the terrain and you get the idea.

There are a few threads recently that have talked about methods for doing this but not sure if they are just variations of the above suggestion or not. The other option would be to look into the 'flyingobject' class and see if there's something you could use there.

I for one would be very interested in what you come up with as I've been contemplating creating a Dirigible for the RTS Kit.
#3
11/01/2007 (8:06 am)
RTSUnits always follow the terrain in the stock RTS-SK, but that'd be easy to change. Lines 501-531 in RTSUnit.cc control units' Z coordinates. I think if you commented out the one line:

location.z = height;

then everything would stop following the terrain.
#4
11/01/2007 (4:36 pm)
Geom! good to see you man! Im following your blog with attention ;)

Edit: typo... it looks like i cant write 2 words without a miss....
#5
11/01/2007 (5:05 pm)
Thanks geom, to the others i dont even want a terrain so ill try geoms solution.

Im actually wanting to implement a homeworld style solution which allows me to by default move on a 2d plane but also be able to move/up down as needed.
#6
11/01/2007 (5:54 pm)
Sweet Ian, keep us informed!
#7
11/01/2007 (10:19 pm)
I haven't heard of anyone else doing a space RTS with Torque, sounds cool.

Putting it in space may be a judicious choice, too, as I could see that simplifying some implementation challenges... like pathfinding, for instance...

@Novack: hey man. Yep, I'm still around. I always enjoy your forum posts!