RTS building placement with pre requirements

upbge
bge
(- Click for resources) #1

Hello,

I made a prototype for a project of mine, and i’m willing to share it with you all.

It’s a RTS building placement system with pre requirements, rotatable buildings, collision checks… so the buildings can be any size you like (0.1x0.1 or 1000x1000 it won’t be a problem), an option to zoom/look around, and it’s very easy to add more buildings/pre requirements(only 2 steps (1. create building, 2. put it’s name into the script)).

I will not post an other version of this, i’ll provide you my working prototype to build your own game from.
rts_building placement.blend (3.19 MB)

Forgot to tell how to rotate the building in the script, so i place the controls here as well:

  • use B key to open the build menu
  • use scrollwheel to zoom in/out
  • hold middle mouse button to adjust the view
  • use Q key to rotate a building
  • left click places the building
  • right click removes the building while dragging it
  • left or right click while build menu is open will remove the building you are dragging
  • if you drag a building and open the build menu, then clicking on an other item/icon will change the building to the one clicked on.

How to give buttons it's own texture
  • go to build menu scene
  • go to layer 2
  • remove the material from the building_slot
  • copy that slot 14 times
  • give every slot it’s own material/texture
  • give every slot the same name as the building/unit it represents ending with .ico, so ‘command center.ico’ or ‘powerplant.ico’
  • now open the script and replace line 269 with:
        building_icon = icon + '.ico'    
        slot = scene.addObject(building_icon, own, 0) 

Done

Have fun with it,

Cotaks

2 Likes

Cotaks shared Bge/UpBge resources
(kengi) #2

ok, for that template i have tryy it’s work fine, just some improvement can do,

preview model before build it
money system
selling system
and on the ui you need change button correspond to the building and the hightlight on the button during the selection, and grey it if not an off money.

for the building need to see about big and small building grid, some building can take like4 square of the grid, other can take just one, so maybe delimit how many square is require to spwan the building, lis as command can conqueur game, like the grid preview building they have and be red when the building cant be build there.

otherwise very good job man :slight_smile:

0 Likes

(- Click for resources) #3

well…

and…

So it’s up to you to adjust it to your needs.

As for:

It’s already doing this, or do you mean a texture on the button? if so take a look at my inventory system, it uses the same mechanism and there i added some textures, so you can get the setup for that there.

Well this system does not use a grid, the placement/movement is like a grid just due to i let it move like a grid object, so you can place/align stuff easier.

You can simply remove the property ground from the terrain, and add a plane on the build locations with a property ground on it, to limit the build space.

0 Likes

(kengi) #4

yes about that sorry, but the system is not the same, the icon need to be different not the same model everytime, ahve you an solution to change that?

0 Likes

(- Click for resources) #5

ok you do it yourself, i’ll explain.

  • go to build menu scene
  • go to layer 2
  • remove the material from the building_slot
  • copy that slot 14 times
  • give every slot it’s own material/texture
  • give every slot the same name as the building/unit it represents ending with .ico, so ‘command center.ico’ or ‘powerplant.ico’
  • now open the script and replace line 269 with:
        building_icon = icon + '.ico'    
        slot = scene.addObject(building_icon, own, 0) 

Done

0 Likes

(kengi) #6

Thx is work yes.

1 Like