Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I implemented PathModifier for path of each enemy in my tower of defense game. So I applied fixed time to path modifier in that enemy complete their path. Like following code describe.

new PathModifier(speed, path);

Here speed define the time to complete the path. But in tower of defense game my problem is, there is a tower which slow down the movement of the enemy. In that particular situation I was stuck. please someone provide me some guidance what to do in this situation.


        Path path = new Path(wayPointList.size());
        for (int j = 0; j < wayPointList.size(); j++) {
            Point point = grid.getCellPoint(wayPointList.get(j).getRow(),
  , point.y);
share|improve this question

If your units have a fixed time in which to complete their path, then they have a velocity. Calculate the velocity and use that instead of the fixed path time. The velocity is pathLength/timeToCompletePath. When a tower slows them, it lowers the unit velocity.

share|improve this answer
I have edited my question with move detail – Siddharth Dec 4 '12 at 16:38
I don't see how that helps. You'll find the path the same way you would before. The difference is how quickly you move along that path. – Byte56 Dec 4 '12 at 16:40

if i understand this correct, you should have some sort of timeModifier that are usable from the outside of an enemy. so that the tower could set the modifier down when it hits with its projectiles.

If that is not an optition, you could try explaining abit how you find your path and how it´s done. and how it´s executed.

share|improve this answer
I have edited my question with move detail – Siddharth Dec 4 '12 at 16:39
What you added, dont realy help. the thing you are missing is how you update your position of the object the direction. – Tordin Dec 4 '12 at 21:37

I found the following solution from other forum so I paste it to help other members.

Well the easiest solution I can think of is: 1) Create new class MyPathModifier(or Something...) 2) Make it extend PathModifier. 3) Create a class level float variable. Let's call it mSpeedModifier. Default value is 1.f 4) create public set/get methods for this variable 5) Override onUpdate:

        public float onUpdate(final float pSecondsElapsed, final IEntity pEntity) {
                return super.onUpdate(pSecondsElapsed * mSpeedModifier, pEntity);

6) When required call setter for this variable. pass 0.5f for half speed. Works both ways, so 2.f will make enemy move 2x faster. 7) Enjoy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.