WarCraft3-like movement, developing kind of a RTS.

Hi there!

I’m trying to develop some sort of RTS game, but less complicated in Unity. So the first goal I set myself to get something done was to get a terrain (with high and low areas), and have one character being able to move to where I click with the mouse, properly animated (running animation, lets say). Well, I thought that maybe then I could start trying to implement a pathfinding system and other stuff.

As far as I know, there is little information on RTS development in Unity, so I did some reseach in several things to start to get my first goal done. Basically I modelled the terrain successfully, I have set a fixed camera that at least for now shows the entire map from perspective, and I imported a .fbx character, an animated teddy bear with the idle animation and the run animation I found in turbosquid.net for free.

What I did is write a script that first, locates the clicking point in the map through RayCasts. I guess that part works fine, and is essential in any movement of this kind. Added RigidBody component to the character in order to get more realism and to be able to walk up hills efficently, and a capsule collider too. But then, I tried to move the character with Vector3.Lerp function while it plays the “run” animation.

It does the job, but when walking up hills, it loses stability, and reacts just like a capsule (quite obvious), it was then I realized that “my method” of getting this done wouldn’t get me to a proper movement of the character through the map.

So, what do you think guys would be the correct way of getting this done? Which functions or aspects of the engine should I investigate? I’ve downloaded previously the Locomotion System to try it out and followed some tutorials, but looked like harder and more FPS, Third Person oriented, and everthing was being triggered with keys.

Thanks for reading and your help, and sorry for the annoyance!

I think using character controller in this case would be more easier than using a rigidbody. And you are right, rts development in Unity is scarce but you might want to check this out if you haven’t. It’s a basic rts camera and movement and highlighting of units. Hope that helps you. :smile:

Using the rigid body will do just fine. I’m on my iPad otherwise I’d give you the link but look in the advance section of the rigid body and you can lock different axis. This will prevent that from happening. using the character control will work fine but I find it easier to use rigid bodies and customize the rest of what I need.

Also just do some simple searching on the forums there’s tons of rts info. Even a community project to get your feet wet.

Thank you for your answers!

Well, this might be a more silly question, but I don’t seem to undestand neither the code, nor the structure of the scripts. For example, I loaded the project (I’m speaking about the C&C style RTS Community project), and I selected the GameObject Tank1. It has only 1 script attached to it, called Vehicle.js which doesn’t have any movement code, and no function related with movement invoked either.

Where can I grab some info about this in order to understand? And I’m having some trouble to make a code with CharacterController to get the movement after I get the map position where I’m clicking.

Thanks again!
I’ll keep on searching, anyway…

Oh my apologies I thought you were writing something from scratch. The main problems I had with the CharacterController were the collisions. It seemed to not be registering 30%(guess) of the collisions so it was making it hard.

I just downloaded the C&C code to look, I didn’t actually load the project up but my assumption after looking at the code is it does not use a character controller just a rigid body. Its uses forces to move the tank(more realistic is most cases). This vehical.js contains all the movement code. Look for in the FixedUpdate function that is where you can see where its moving the tank forward and backward. The Update function contains some code that gets used by the code in FixedUpdate, all of the rotation code is also in the Update function.