This is a simple grab object script:
def grab(cont): own = cont.owner grabcol = cont.sensors["grabcol"] if own["active"] == 1 and grabcol.positive: target = grabcol.hitObject target.applyForce((own.worldPosition - target.worldPosition) * 100000) target.setLinearVelocity([0, 0, 0]) if not grabcol.positive: own["active"] = 0
It identifies if boolean active is true then applies a force between the collision box and hitObject. It then sets the linear velocity of the hitObject to 0, 0, 0.
I would like to make this more like the valve source engine method of grabbing objects (prop physics). This method “loses” the object when moving too fast and when the grabbed object collides with another object it goes flying at enormous speeds… Any fixes I can make?