Physics LOD[question]

I am looking for a way to make a physics LOD. It means that I have a rigid body objects that use rigid body joint to be joined with ground. I am doing it to achieve an effect like bushes would be real(when you walk/drive over them, they are being pushed, but they keep in their position). What I want to achieve, though, is disabling the physics on them when they’re far and make them become physical again when they’re close. Is it possible to do somehow?

You can restore dynamics and suspend dynamics with logic bricks and probably with python.

You need dynamic object in your scene and add to it [Always]•••[And]•••[EditObject]. In this logic setup on dynamic object, try to change EditObject to dynamic and then leave it at suspend. Now mouse over that “dynamic suspend” text and see what command it uses. Post it here.


from bge import logic


def physics(cont):
    own = cont.owner
    scene = own.scene
    for ob in scene.objects:
        if "pLOD" in ob:
            dist = ob.getDistanceTo(scene.objects["Player"])
            if dist > ob["pLOD"]:
                ob.suspendDynamics()
            else:
                ob.restoreDynamics()

I figured it and tested - it works;)
(“pLOD” property is for all the objects which use physics LOD. It should be set to the distance value in which it switches on/off. I execute the script in module mode with always sensor and tick rate of 5(because I don’t need to check this each frame)).:slight_smile:

I am glad it worked for you.I would love to see it in action working with the grass in a video.

Yes, I will make it right now:)

I would love you to show one your cars driving on dynamically loaded terrain.I have two scripts that are from other people.
You can use for that.

Dynamicly loaded terrain? I may need this, indeed.

BTW, I don’t have time any more, the example will be tomorrow.