While this could be considered a general coding question, it's roots are in game code (UnrealScrip). I have trying to work out a single equation for three hours now and it's beginning to REALLY annoy me. What I need is an object that goes towards another object (This case, a point in front of the player) at an increasing speed, and if the object is beyond a certain distance, not move at all (Ie, a magnet attraction system of sorts)

Now, the variables that I've got to play with are the object's trajectory in vector format to get to the point (Infuriatingly, I cannot use it's position, at least I don't think so), the maximum distance in float format and any other number.

The trajectory can be divided or multiplied, but cannot be the multiplier or divisor. It can only add and subtract with other vectors.

Now, I have managed to get the object to move towards the player with a decreasing rate, but I cannot for the life of me inverse the calculation.

//MovVec -> The vector indicating movement - VECTOR //fMaxDist -> The maximum distance allowed - FLOAT - 1000 //fSmoothRate -> Another function to help in smoothing the movement - FLOAT - 2 //finMovVec -> The final vector from which the Move() function acts on - VECTOR finMovVec = MovVec / smoothRate; //(Moves towards us at a decreasing rate) WORKS finMovVec = smoothRate / MovVec; // ILLEGAL (float / vector) finMovVec = MovVec * smoothRate; // Too fast! finMovVec = MovVec - (MovVec / smoothRate); //Same as first finMovVec = MovVec - ((MovVec * smoothRate) / (fMaxDist / MovVec)) //This and anything like this either brake or result in the first function...somehow. Or a constant velocity throughout)

If I can just get it to move towards the player at an increasing rate, I can probably work out the distance limitator.

If I can solve this by modifying the locational values before hand, that would still be good.

MovVec = DestLoc - Location; //DestLoc is correct, Location is the objects current location

For those of you who know UnrealScipt may say 'Why not use SetLocation()?', well, I've tried and that resulted in some other issues, so I have to resort to 'MoveSmooth()'

Even suggestions will help greatly. I will provide any other information required (Though that should be enough)

Thanks,

Dan