Game Development Community

Limiting A Units Movement

by Chip Lambert · in RTS Starter Kit · 04/14/2008 (2:23 pm) · 6 replies

Hey RTS Gurus :)

I'm getting back into the kit and have it updated to 1.5.2. Now come questions :)

I want to limit the movement of units. For example, the Rifleman can only move 30 feet in any direction. Whats the best way to go about accomplishing this? Also with this I'd like to do some kind of notification to the player saying that the movement is to far out of range, etc.

Thanks for any info!

Chip

#1
04/14/2008 (7:41 pm)
Hello Chip, glad to see you.

The first that comes to my mind is a simple vector operation. Something like:
%distance = VectorDist(%origin, %destination);

if (%distance <= 30)
   %unit.setMoveDestination(%destination);
else
    echo("The destination is too far");

I dont know about the result metric though, I think its in meters.
#2
04/15/2008 (1:11 pm)
Thanks Novack :)

Would this go in player.cs in the Player::setMoveGoal(%this, %dest) function or is there somewhere else it should go?
#3
04/15/2008 (8:23 pm)
Well... that depends on you own implementation, but I think that lines should work if you put it on -for instance- serverCmdIssueMove() (commands.cs) with some arrangements.

However, I remark yet again on the need of understanding of the code. Its useless to ask for help on new specific features, without understanding (or the will to understand) whats happening there. What myself or others could write here have to be taken as guidelines, not as code or solutions that work "out-of-the-box".
#4
04/15/2008 (8:27 pm)
Thanks Novack. I understand whats it doing, and this was the implementation I thought would work, at lesat in the pseudo code I scratched down, I just didn't know which function to use. I really need to brush up on all these functions in TorqueScript.
#5
04/15/2008 (8:31 pm)
Hehe, yup, I saw that you knew what you were talking about by reading other posts of yours, I just thought for a moment of another case of "premature coding" :) Sorry!
#6
04/15/2008 (8:34 pm)
Heh no problems Novack, no offense taken at all. I'm a pretty good programmer with several other languages, just know my TS as good as I should ;). Thanks for your all your help.