Public Group

# General think patterns concerning unit handling in RTS

This topic is 4581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone! I am currently developing an RTS for the (somewhat obsolete) Shockwave3D engine. Please excuse me if I'm not supposed to post here since I use the SW3D engine. Well, this is my first real game ever, and I have no education or experience whatsoever in game development. I just felt like I could do it. My question is, what is the general way to make unit handling to work? Right now, I am stuck with making the unit rotate towards the goal (where I clicked) and then moving there. I just can't figure out how to make the unit know how many degrees it's supposed to turn. It's got something to do with the angle between vectors right? Well, anyway, I would be super happy if someone could shed some light on this for me, possibly with a couple of examples? Thanks for reading!

##### Share on other sites

http://en.wikipedia.org/wiki/Trigonometry

##### Share on other sites
So I see...
I feel quite dumb when I ask this, but, how can I implement it?

##### Share on other sites
Hey, mate, I'm a newbie as well, there may well be a much more simple way, I don't know. But trigonometry is generally used to rotate objects in 3D and even 2D. Of course, I've no idea how to implent it but I guess it depends on the API. Probably your engine has some functions or something...

Sorry I can't be of no more help.

##### Share on other sites
Hey newbie friend =)
You guessed right, the engine I'm using has got a lot of functions for that, but I just want to know the general way to go about when doing this in an RTS. At least I hope it is kind of the same technique used in all engines. Just as 1 + 1 = 2 in all nations in the world. Thanks for trying! =D

##### Share on other sites
Long day, forgive me for lack of direct links...
In a standard RTS 'moving' units to a destination could be achieved through the use of ray picking (in order to find the vector to where you have clicked on the terrain mesh) and the Dot Product between the units direction vector and the vector for where you click.

1) Find the direction vector for where you wish to rotate the unit. (Using Ray Picking perhaps)
2) Find the Dot Product between this vector and the units direction vector. You should already have the direction vector for the unit.
Then DotProduct = |A|*|B|cos q , q is the angle you want to rotate by.

There are built in functions in the Direct3D vector class to perform vector operations such as the dot product. Direct3D.Vector.Dot(vec3 Left, vec3 Right)
3) Apply the rotation using the found angle (q).

Would be very useful to know of the language, and any API's you are using! :)

##### Share on other sites
Sounds good... but hard for a newbie like me. As for now, I'm having problems even finding the vectors of my meshes. The language I'm using is actually "lingo" I don't think it counts as a programming language. I'm using the built in 3d"Xtra" in Director from Intel called "Shockwave3D". I'm sure you've seen it on the net. I have the possibility in using javascript for my scripting, but I don't know nada of javascript and as far as I have seen there are no differences in their funcionality within this engine.

##### Share on other sites
I've never actually used Shockwave3D, but if thats the case it is unlikely you will need to delve into the math directly. Your best bet would be to look into other examples of what people have done using that language.

##### Share on other sites
Yup and that is what I am doing. But unfortunately, the forums for SW3D are sooo slow, takes days to get replies, so I thought that I could maybe figure it out myself by going to the _REAL_ developers. I don't understand why I haven't started for real with programming yet... probably because it seems so daunting. Thanks for the help!

##### Share on other sites
If you are developing software with code in any way, even if it is completely visual, you are programming. I think you would be surprised at how quickly you will pick up concepts you find daunting...If you are programming or not isn't define by how difficult it is!
Blagh..Getting OT here..i'll save this for another thread. :)

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632977
• Total Posts
3009676
• ### Who's Online (See full list)

There are no registered users currently online

×