RTS controls problems

Hello, im trying to get my RTS controls to work but my steering target wont work as i wanted it to.
Here is my blend.

RTS test.blend (493 KB)

Controls:

  • Left click + hold and drag like a box over the cube = Selecting the cube (Like normal selecting in RTS(It will become a blue wire around the cube if selected))
  • Right click (When selected) = Move the cube

I have tried to make it easier to orientate in the code by commenting.

My problem is you have to right click twice or more after the first right clicking.
It seems like the steering target want to be reset before it can get a new target.
I am adding a cube everytime i right click, which is the steering target and trying to make the added cube dissapear when right clicking again to update the steering target.

Any idea’s why it does this? Any other idea’s how to make it work (a workaround maybe)?

Thanks :slight_smile:

If you don’t understand just ask~

Been following Goran Milovanovic RTS tutorial so alot of credit to him. ^^

possible solution is to use one target object for the steering, instead of cloning the node, place the node where you click.
every time you right click you add a new node, while the old node is still there, this causes the object to go after the second instead of where you click after a few times.

Thanks for reply. Yeah I realized how stupid my system was (facepalm), just changed it to a system like that. I’m using empties which is parented to the object and unparented when i right click to place it out so it can follow it and when it is close it parent it self again and deactivate the steering.

RTS test2.blend (575 KB)

(If in camera mode)
W/A/S/D = Move camera
E/Q = Rotate camera
Scroll wheel = zoom in/out

Now I just have to figure out how to set new coordinates when I move a group of objects so they don’t collide, ideas would be great. :spin:
Maybe parent the movement empties with an offset.

I think the best way is to carry over the offset of the original position, and reduce it with how many characters are selected.

Hey, I made a selection box script for a RTS some time ago. You can use it for selecting multiple units at the same time using a rectangle. It should still work with the newer versions of Blender.
If you want to poke around with it, you can try it out here:

http://www.mediafire.com/download/8bnk96xwbq4ccgs/selection_box.blend

it addresses one of the problems Blender has in selecting things based on their position on the screen. I can’t remember exactly how I did it back then, and I know I found one other more elegant way to do it recently (with vectors I think…) but I can’t remember where I saved that demo file, so this one will have to do. I’m providing it as is, I probably won’t be able to answer any detailed questions about it, but you can probably find enough good stuff in there for making your own selection box system.

Attachments

selection_box.blend (563 KB)

That’s a really nice looking selection system, I sure will study it! I like the idea how it is 3d selection :). Right now I am using 2d selection and measuring the screen and taking the objects position on the screen (But I don’t have a drawing method for it yet so it is hard to debug)

this is a nice looking box. I put it in my game, but might have made some boo boos.

My box is off. when it draws, it doesn’t start drawing where the mouse is and does not track the mouse movement correctly.

If I move the “aim” object, it moves the selection box a bit, but I just can’t get it anywhere close to right.

If I move the “select” object, it doesn’t appear to do anything.

Anyone have any advice or is anyone else using this?

make an object that is a cube with its origin at a bottom corner that is 1x1x1

click = set it to use cube bound and sensor mode

left click places this object, and holding it places the other corner using align axis to vect,

sensor uses sensor.hitObjectList to get at entries.

alternatively get all items in a range from scene.objects with a prop, and have distance from intial click point form a radius based on the center of the curre t hitPoint and the startpoint , releasing click finalizes the selction

I will post a blend or 2 soon if I get the chance

If you do get a chance to post that blend example, I would appreciate it anyway. This select box in 3d is hard.

c_select.blend (526.5 KB)

I ended up using radius / a actor list as scaling a collider is not working correctly anymore ?

1 Like

Looks really nice! If I can sneak away from work this weekend, I’m going to play with this. I’ll let you know what happens.

I put this in my game and made it look pretty and it’s awesome!

It looks great and it doesn’t lag and it’s relatively simple and no talking to the graphics card and no aiming rays or tangents. Have you considered an exciting new carrier as a GOD? I think you might be cut out for it.

Do you mind if I use this in my game? I’ll of course give you credit for it.

no problem and no need to credit unless you want

cc0