RTS - Little Help Please

I've been searching around the forums for a similar post but could not find one.



Question : Could someone please help me get started on how I might make it possible to select units in an RTS game, I think I have an idea in my mind for most of the things except I don't know how I'm going to know which of if a unit is being selected on a mouse click event. Any help in this area will be greatly appreciated. After that I think I have ideas of how I might display that they are selected and do most of the other stuff.



Extra: Ok I thought of some other things that are very similar. Is there a way that I can tell where on the terrain they are clicking too? such as a move command to a point on terrain?? And also I thought about it and I don't really know how I would do a multi select either(A box select) but That part can wait I can do one step at a time.



Thank you.

Hello,



Try the the test class TestPick.java.



There's a class called PickResults which outputs the Spatials that you are picking in the scene.

An implementation of this can be seen in TestPick.



something like this:

if( MouseInput.get().isButtonDown(0) && shotTime > 0.1f) {
            shotTime = 0;
            Ray ray = new Ray(camera.getLocation(), camera.getDirection()); // camera direction is already normalized
            PickResults results = new BoundingPickResults();
            results.setCheckDistance(true);
            scene.findPick(ray,results);
}


where the variable results is used to store the spatials that your mouse picked on.

Thanks, Apparently I need to be more familiar with the test implementations.



I could still use some help on which point I'm ordering a unit to move to on the terrain but I will also check the tests for this functionality, Thank you.



Edit looks like testTrianglePick will help me with this, Thank you.

Zergleb said:


I could still use some help on which point I'm ordering a unit to move to on the terrain but I will also check the tests for this functionality, Thank you.

*Edit* looks like testTrianglePick will help me with this, Thank you.


terrain pick,  :D
http://www.jmonkeyengine.com/forum/index.php?topic=9234.msg71721#msg71721