Creating a selection box for an RTS

Hello fellow blender-ers!
I was wondering if anyone knew how i could go about drawing a selection box in the game engine. specifically for an RTS. I already have all of the mechanics down for the RTS and now I need a way to show the player where their selection box actually is.

Iv’e looked into the bge.render.drawLine funtion, but this causes problems because it requires two 3d vectors. Whereas I would like to draw on 2d screen space.

I’m guessing bgl would be the next step, but I havn’t got much time on my hands at the moment.

Thank you
-Kendrick

One way that springs to mind would be to parent an invisible plane in front of your camera. Then you can ray-cast onto that plane to get 3D coordinates that will draw a non-perspective box on your screen.

Besides that, going straight to OpenGL would let you use ortho perspectives so the drawing would be easy, but if you have not done that before then it is a steep learning curve.

the selection box plane/cube thing can have the property “select”
do “replace mesh” on and off with another texture/ shape indicating they are “selected”
then have another plane spawn the same size with the property “get” and have this in each item to be selected,
the items to be selected need this

property X - booleen

On collision with property =select-------------------------------and--------------------------property toggle (name your prop)
if X =TRUE----------------------------------------------------and-------------------------mesh change 1
if X =FALSE---------------------------------------------------and-------------------------mesh change 2

On collision with property =Get-------------------------------and------------------------set mesh back etc and message to collector or end object or whatever

Watch this part of Goran’s video tutorial on RTS controls.

Beautiful, Works perfectly!!

An rts game template is welcome. :slight_smile:

An rts game template is welcome.

This, and a tutorial is what I had planned.

What would it include?
Im following youre tutorials and was wondering, when would you make some advanced one, like an armature character walking, climbing etc.