I’m reading Beginning Blender and trying to use a little Python in the BGE. A sphere rolls down a ramp and then drops off a plane. The following script is meant to reset the initial position after it falls:
import bge
object = bge.logic.getCurrentController().owner
if object.worldPosition2 < -3:
object.worldPosition = 0,8.62,2.84
object.linearVelocity = 0,0,0
I have a sensor on the sphere set to Always with pulse true enabled. I have a Python controller set to the script in the text editor window. I push P and the sphere rolls off and doesn’t come back. The position to reset to is the coordinates for the original location.