?force acting for a certain amount time?

Hi all… How would I get a force to act… for say eg. 3 seconds on a object and then stop? How would I write something like this in python? thanks:D

you send a true pulse every time your script is run for 3 seconds, then send a false pulse

timer properties are useful for watching time pass… this is pretty trivial stuff

I don’t think he knows how to script for the BGE. Someone should write a few straightforward tutorials about the “Py BGE API” for the newcomers.


Logic brick setup:

sensor->pyscript->motion actuator

!sensor must have true level triggering “pulse mode” enabled!


Add a Timer property, name it “time”.

import GameLogic as G
cont = G.getCurrentController()
own = cont.getOwner()
#Sensor that triggers the action:
trigger = cont.getSensor("SensorName")
#Actuator which applys force when sensor is active:
motion = cont.getActuator("ActuatorName")
if trigger.isPositive() and own.time < 3:
if not trigger.isPositive():
    own.time = 0

Hope this helps.

Thanks Social that’s sweet! Yeah I’ve done some beginner scripting tuts but they don’t go into enough detail on how to use it well. Your script has taught me a lot.

I’m happy to help.

thats real that is real helpful thanks social.