RTS-style right click movement
RTS-style right click movement
I am currently implementing a game with several stylistic influences, but I need to be able to move these units to a location simply by right clicking.
Basic info:
Space based game, meaning no floor mesh.
Assume that I have selected only one unit, using the ISceneMeshNode* name of "current"
Units are unable to move on the 3rd dimension, they are limited to 2d movements.
Does anyone know how to do this?
Basic info:
Space based game, meaning no floor mesh.
Assume that I have selected only one unit, using the ISceneMeshNode* name of "current"
Units are unable to move on the 3rd dimension, they are limited to 2d movements.
Does anyone know how to do this?
Get the ray that starts at the position the current camera and goes in the direction the camera is looking at (ISceneManager::getSceneCollisionManager() )
Get the collision point of this ray and the plane where your units walk over ( plane3d::getCollisionWithLine() for example)
And then move the node to this position. (For example using a FlyStraightAnimator)
Get the collision point of this ray and the plane where your units walk over ( plane3d::getCollisionWithLine() for example)
And then move the node to this position. (For example using a FlyStraightAnimator)
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
The homeworld style would be acceptable, with two problems. One, I would still need to get a ray trace onto a nonexistant plane in order to determine where to expand the circle to. And two, I would have to draw a circle, something I am not familiar with doing.
I would like to have an 'assumed' plane. This means that somehow I would like to be able to have all the units on the same given plane, then be able to right click and determine a coordinate for that right click.
I would like to have an 'assumed' plane. This means that somehow I would like to be able to have all the units on the same given plane, then be able to right click and determine a coordinate for that right click.
Code: Select all
plane3df( vector3df( 0,0,0 ), vector3df(0, 1, 0 ) );
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
from the documentation for getIntersectionWithLine() (http://irrlicht.sourceforge.net/docu/cl ... 88721e2f30)
[...]
lineVect Vector of the line to intersect with.
linePoint Point of the line to intersect with.
outIntersection Place to store the intersection point, if there is one.
[...]
How could I possibly know the point of the line to intersect with? I have a ray from getRayFromScreenCoordinates (core::position2d< s32 > pos, ICameraSceneNode *camera=0) to put into lineVect, but linePoint?!?!?!?!?
HELP!! that's the worst idea! I am very confused by this documentation of getIntersectionWithLine.
What am I supposed to insert into linePoint???
[...]
lineVect Vector of the line to intersect with.
linePoint Point of the line to intersect with.
outIntersection Place to store the intersection point, if there is one.
[...]
How could I possibly know the point of the line to intersect with? I have a ray from getRayFromScreenCoordinates (core::position2d< s32 > pos, ICameraSceneNode *camera=0) to put into lineVect, but linePoint?!?!?!?!?
HELP!! that's the worst idea! I am very confused by this documentation of getIntersectionWithLine.
What am I supposed to insert into linePoint???
Use getIntersectionWithLimitedLine(...). It's parameters are much more obvious, and if you're using a ray from screen coordinates and you can see where you're clicking (and the camera's far plane is thus beyond that point) then your line will pass through the plane (so it doesn't matter if its limited).