I would like to be able to control an object moving along a path in the BGE. I have looked at the Action actuator, but that seems to just play the animation. I want to be able to control the speed and direction of the object as it moves along the path. Something like a car going down a road. Is there some way to accomplish this??


1 Answer 1


I could not find any info and this, so since i figured it out, i would post the answer. I used logic block and a python scrip. The example is not for a follow path, but just a simple cube animation.

The game goes as follows: Press space key to start animation, press again to stop the action. Press the F key to speed up the animation, and press the S get to go slower.

I included some images.

import bge

def main():

# max frame of animation
maxFrame = 100

cont = bge.logic.getCurrentController()
own = cont.owner

frameAct = cont.actuators['Frame']

currentFrame = own.get(frameAct.propName)

# limit speed to between 1 and 10
speed = own['speed']
speed = max(1,speed)
speed = min(10,speed)

speedInc = (0.10*speed)

currentFrame = currentFrame + speedInc

if currentFrame > maxFrame:
    currentFrame = 1

frameAct.value = str(currentFrame)


Overall layoutLogic Blocks

  • $\begingroup$ Note: When using this on a follow path constraint, the action must be baked into key frames for this to work. $\endgroup$
    – BigEFrom84
    Nov 30, 2017 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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