change static object to dynamic in the game

how can I change it while the game runs?
thanks for all your answers

By using states! 1. make the object dynamic. 2. add a always–>and–> Edit Object[Dynamics(Suspend dynamic)] logic brick 3. add your state changing setup (Space bar): Keyboard[SPACE]–>and–> States[Set(2)] 4. on state 2 add: always[level]–>and–> EditObject[dynamic(Restore Dynamics)] 5. If you want to revert, use step 3, and replace 2 with 1. Remember, static objects have no dynamic(Duh), so you must use Dynamics first. Good luck!

If you are using Blender 2.5 and want to use python for this, here’s a script I typed up.
Connect a Keyboard sensor and an Always sensor to the Python script controller.


from bge import logic as l
c = l.getCurrentController()
o = c.owner

# Get keyboard sensor named "Keyboard"
key = c.sensors['Keyboard']

# Set initial properties and physics
if 'dynamic' not in o:
    o['dynamic'] = False
    o.suspendDynamics()

dyn = o['dynamic']

# Enable/Disable dynamic physics
if key.positive:
    if dyn == False:
        o['dynamic'] = True
        o.restoreDynamics()
    else:
        o['dynamic'] = False
        o.suspendDynamics()

Example:
dynamicExample.blend (68.7 KB)

thank you very much for the code, I didn’t know how to write something like that(until know) :slight_smile:

thank you too