RTS Building System

Hey Everyone. I hope that i chose the right forum for this, as this is neither a WIP, nor a finished game - its rather just a test or a demo. I finally found some time to work on blender - and i started to play around with the game engine. My first attempts were more focused on getting simple motion etc, but as soon as i found out how simple the logic brick system really is, I went for something more complex. The process of creating this demo was not really “hard” but rather time consuming. I used mainly logic bricks to create this building system - python scripts were used for Bloom,the “minimap”, some data for the UI and for the mouse tracker. I used Goran’s 3D Mouse tutorial to create the basic setup [ http://www.youtube.com/watch?v=H44cBzjxbh4 ] .

I plan on creating tutorials for this “building system” - currently im finishing a build-grid, which makes it easier for placement detection. This setup here is using rays to see if a building is underneath the cursor.

Even though the logic looks complex its rather just messy, i didnt use layers and couldve avoided some doubles by using a more structured setup - but as this was just a testwork i didnt really care about cleaning things up.

Thank you for taking the time to read / watch. I am open for any comments/questions etc. :wink:


I created a build-grid that works with logic bricks mostly. Python only sets the block’s origin to the origin of the plane so that it will always move in 1 blender unit steps and not freely like in my other RTS demo.

1 Like

this looks really solid both visually and functionally, and wow all with logic bricks, Keep it up looks delightful :eyebrowlift:

looks great and very impressive!
Good work!
Ahhhh, the Logic Bricks interface really needs a big improvement!

Nice demo, just like a real RTS game. :slight_smile:

Thank you guys :slight_smile: I really appreciate it!
This is certainly not suitable for any sort of “real rts” as there is too much to deal with concerning unit selection etc. But I think this might be quite useful for other cases as well - e.g. for a Tower defence or something like that - I´ll probably aim my tutorial more into that direction.

The only issue I had was turning mipmapping off for only the UI - so it would´nt get as blurry, I could´nt really find a solution.

holy **** this is awesome!
did you make the building models?
did you make the hud?
i love everything except the sounds for some reason i dont know :stuck_out_tongue:
and i would recomend to learn and use python, im currently working on a rts game, and everytime you add a new functionality it adds a mess of logic bricks, however i havent come to the part of the buildings, i rather focus on the units, and later i will make buildings as units, but with a speed of 0(they cant move!)

it looks awesome, keep it up!

Nice models,

Thanks again! Yeah I created the models myself - They are a bit too high poly I believe - I couldnt find information on how big a building in RTS games nowadays is. As I said in the youtube description they are rather rushed, I guess i couldve done a lot more detailing work. I plan on doing so if I ever work on a real project.
The HUD was really just a Texture by cgtextures with some custom shapes added. I would´ve liked to detail it much more, but the mipmapping took away a lot of the fine lines.

To the sounds : I realized when i uploaded that its kind of cheesy , especially the rotation sound, it would suit some children comic game more than a rts or “war” game. :smiley: But yeah i made those in about 30 minutes, as my intention was really to not upload only a video of 3 colored cubes being placed. But you are right, I dont like them much either.
For the python scripting : I really tried following Goran´s youtube series about python scripting, to sort of learn the basics - but it seems that I will never be a good friend with python scripting in general :confused:
If I can help you with your rts game just leave me a message.

Edit: oh yeah and I think this is certainly a nice variant to deal with the unit selection - setting the building to 0 speed. But you need to implement some sort of dynamic navmesh as well - which would be my biggest concern when really diving into an RTS project - if your buildings are placed - and they obviously should be much bigger than your units- will they be detected as obstacles etc.

I heard that if you make it a .dds texture and don’t pack any mipmaps, but tell it to use dds mipmaps, it will be displayed without mipmapping.

Anyway, it looks great. I’ll probably steal some of your ideas :slight_smile:

I will try that as soon as I´m at home, thanks =)
You may use any of those :b I got my ideas mainly from starcraft as I´ve been an excessive player in broodwar (minimap, changing of model to red if there is no space etc. ) and the energy thing i remembered from command and conquer red alert - i didnt play any newer version though.

the models are great, they are just perfect, i love the modeling and texturing!
oh i see what you did there with the HUD, it looks amazing anyway

oh yeah, navmeshes, im trying to deal with that aswell :stuck_out_tongue: i thought that you could have a navmesh parented to the building when it spawns, so when a unit is close to the building, it will stop using the navmesh of the terrain and will use the navmesh of the building instead, but its kind of a dirty way of doing it :stuck_out_tongue:

uh, thats why the thing of energy seemed like familiar to me :stuck_out_tongue:

To be honest - I was quite lazy and took tileable textures to not have to deal with UVs that much - I baked it afterwards to 4096x4096 textures as well as the AO- it was a rather bad choice for the loading time :D. Sounds good for the Navmesh - tell me if you have results - and there is never a bad way :b people wont see your source - if it works its fine ! I thought about a ray that makes the unit rotate until it can move freely again - but that would lead to bad pathfinding I believe.

I think everybody played one of those games - I just remembered when the Radar turned off because of missing energy- maybe this was my way of handling my angry memories with that :smiley:

uh 4096 sounds bit… large, and we all use tileable textures so we dont have to deal with seams haha
and yeah i hated when the enemy bombed my energy structures so my defences would go down… grrr

Well it certainly is too large for that zoom level - But as this is one single object the space was needed for higher detail - so even the small parts had enough space in the texbake to be detailed. I think a LOD system or smth similar would be great for this case.

Haha it’s always nice to have more than 2-3 resources to be aware of - it makes things more complex and sometimes more fun if used correctly. So energy certainly is a very strategic aspect that can increase the players enjoyment. But in some cases not so much :b.

A quick update : I still didn’t find the time to create a tutorial. I created a build-grid though, which will also be added to the tutorial list.

// video also added to the Original Post

I guess the implementation into a real project ( which I’m planning on - no RTS though, rather a puzzler ) would require a visualization as seen from 00:20 on - so one knows which spots are free and one can calculate how much room one requires.

edit: I just tested another thing : I used rays instead of mouse-over for the collision - I just need to adjust that only the blocks fire rays that are within the size of the building to be placed.

I would like a script that if i add a object with the add object actuator, it will be placed at a certain position not overlaping another added object.I am trying to make a terrain lod that works well.Right now it adds objects and makes them overlap.which looks real bad.I want the script to be triggered by a radar sensor. Could you make a tutorial for that?

Hey 3D solar system builder,
unfortunatly I’m really bad at scripting. This was based on Logic-bricks mostly. You should ask some of the coding gurus on BA likeProf.Monster, Goran or agoose77 - I started using the GE not too long ago so I don’t really know much about python scripting etc. For me I solved the overlapping problem by using boxes in 1x1 Blenderunits arrayed at the size of the building-to-be-placed that checked for collisions with -Z rays. - This set of boxes obv allows for an easier way of placing buildings and calculating space ( e.g. used in StarCraft ).

This Grid is basically just a workaround to a real python script - instead of setting mouse positions with python i just used a grid of planes and set the mouse to origin - a rather simple method but it works for small projects. I don’t know about the functionality within a real environment, as there are probably limitations that python doesn’t have.

Are you using a premade LOD? Or did you create it yourself? If it’s premade you should maybe just contact the creator - or post a new thread about the issue as I can’t really follow where your problem occurs.

Oh I see. You could add empties that will add the plane at a fixed location whenever the “player” is near - that way you will have them fixed and not rotating. Like set the logic of the “add object” to a fixed empty and when the radar spots an object at the location of the empty the mesh will be added.

Yours is obviously always taking the orientation of the player into account when adding the planes.
you could add an object that is following the player with locked rotation ( vertex parent ) that will add the new ground-planes - you move the object further away so that a new plane will always be added after the last one, this way they won’t overlap.

A third idea that comes into my mind solving this is moving the origin of the plane to its border - that way a new plane will always be added after the last one.

The last solution does not work unless i do not understand.A blend file example would be nice.

You should certainly consider asking someone who has pythong knowledge - lod systems are easier to create with python. I dont know much about the radar actuator - i used collision in this demo :add_planes.blend (502 KB)

controlls are w and s - this is just the basic displaying what I mean by moving the origin - the empty will move exactly the range of the plane’s size and add it - with it’s origin at the border it will be added seamlessly right behind the last plane.

If you set the motion of the “controller walls” to a given size that is equal the ground plane’s size, and you move the origin to the border of the plane - then each plane will be added right behind the next.

edit :\

They are 25BU each - the main plane is 50 - so they are halfsteps every time so to say. You could add a player that is at a certain distance to the cube which controls the map buildup - so you are out of vision range of the plane being added. And you need to implement some sort of ray system that deletes planes which are out of range - this attempt though aims at a totally different mechanic than yours so I doubt its really helpful.
I will take a closer look at it tomorrow and see if I can modifiy your blend file - it’s 3:00 A.M. here so bear with me :stuck_out_tongue_winking_eye: I’m quite tired right now.