Is it possible to change obj type from 'dynamic' to 'rigid body' in game?

Is it possible to change obj type from dynamic to rigid body while the game is running?
I can’t find any property or function in blender game python for this.

Yes it is, with logic too, use the edit object actuator, go to dynamics, and set it uo so that it will enable rigid body, or disable, play around with it, thats the best way to learn.

Thanks I’ll try it!

P.S. I doesn’t work for me, enabling/disabling rigid body via Python or game actuators does not working.

Somebody find the solution for that ?

because it’s not working for me too.
I cannot enable/disable rigidbody.

The only thing I can do is suspend it but when it’s supended , it’s seem to have collision detection but no friction.

What I try to do is :

A static cube is fix in the air. A Rigidbody fall on it and if the velocity multiplied by the mass is enough , the fixed cube become dynamic too and start to falling at it’s turn.

For now I did all the thing and all working fine by suspend dynamic with the edit object actuator but the only thing is the falling cube bounce and slide on fixed cube if the force is not enough. This is not the result I want.

Have you tried setting the object to be rigid body to begin with and then disabling it when the game starts, then enable it later on?

yes

I put a Always sensor with in “tap” mode connected to a Edit object actuator in Dynamic mode with “Disabled Dynamic” activated at the beginning. And the object move … I dn’t know why. But if I switch it to “Suspended” just the option next “Disabled Dynamic” … it’s working. :frowning:

I see, what seems straightforward isn’t working, better submit this as a bug report to the GE tracker then, it may have broke when Bullet was updated a few months back.

A workaround that works for me is to have two identical objects with different physics settings. Have one as rigid body and one as dynamic then use addObject and endObject to switch between the two.

Do note though it doesn’t diminish the need for this bug to be fixed, what if you have dozens of unique objects, it would take a lot of tedious work to get the workaround working for all of them.

:frowning:
Thanks AceDragon
I try to post on the bugtracker when I have time.

Nobody have a idea for a workaround until is fixed?

There is just setting the object as a rigid body and then using a simple python script to get the object’s orientation and then keeping the object at that orientation, this would emulate the dynamic functionality in that rotation to be constrained to the one it started with. Something like…


if ob['rigid_body'] == 0 or ob['init'] == 0:
    savedOrientation = ob.worldOrientation
    ob['init'] = 1

if ob['rigid_body'] == 1 and ob['init'] == 1 :
    ob.worldOrientation = savedOrientation

What this would do is get the orientation of the object when a property named rigid body is set to zero, and when it is set to one, it would restrain the orientation to the last recorded one, it also would use an init variable to get the orientation when the game starts if it’s to start constrained

FunkyWyrm: thank for the idea but I already think it and like DragonAce said, it’s not the best thing to duplicate all objects in a huge scene. But thanks again

AceDragon: by orientation you mean position and rotation? It’s sound a good idea to force by script the objects to return to it’s initial position/rotation. I try it when I can. Hope this not create vibration or something like that.

Okay , I find in the API docs than this feature is not worked with Bullet for now :frowning:
Hope the AceDragon idea work!

Ace’s idea would work, but there’s a slight issue in the script. It should be:



if ob['rigid_body'] == 0 or ob['init'] == 0:
    ob['savedOrientation'] = ob.worldOrientation
    ob['init'] = 1

if ob['rigid_body'] == 1 and ob['init'] == 1 :
    ob.worldOrientation = ob['savedOrientation']


IF you’re using Blender 2.5.

Ok I try to keep a RigidBody static by forcing it to keep the same location with python script plug on a “alway” actuator. It’s working … until a object fall on it and pass trought slowly:


import bge

objcontroller = bge.logic.getCurrentController()
obj = objcontroller.owner

obj.localPosition = ([0,0,0])

I try to put the same location and reset is velocity too. The result is better but it’s act like a spring when a object fall on it :


import bge

objcontroller = bge.logic.getCurrentController()
obj = objcontroller.owner

force = obj.worldLinearVelocity

obj.worldLinearVelocity = -(force)
obj.localPosition = ([0,0,0])

Testing my code is simple. Create two cube with RigidBody activated and put my code on the bottom cube with a ‘‘Always’’ sensor with a frequency of 0.

Somebody have a idea ?

Hmm. To turn a dynamic object rigid body, just apply a torque for a minuscule length of time. This sets it to rigid body (even through logic)
I don’t know how to set it back though…

It’s probably best not to rely on bugs like that for games, since you’ll never be able to upgrade your project. You may wish to consider either grabbing an earlier build in which this works, or picking up one of the latest from GraphicAll and see if it fixes the issue.

It’s not for a game but for a setup for destruction with rigidbody. I need object to be static until a rigidbody hit this object with alot of force to become a Rigidbody at is turn and fall down and hit others static object at it’s turn. All working fine and look really cool exept for the “suspend” dynamic problem.

You can enable rigid body physics on dynamic object by applying some torque. Even 0.001 is enough.
Example - rigid.blend (940 KB)

It’s not for a game but for a setup for destruction with rigidbody. I need object to be static until a rigidbody hit this object with alot of force to become a Rigidbody at is turn and fall down and hit others static object at it’s turn. All working fine and look really cool exept for the “suspend” dynamic problem.

You can suspend dynamics for all rigid bodies, that way they will look and behave like a static objects, and then restore the object dynamics not when another object hit it, but a little bit before the real collision. ,that way you will work around the suspend/restore dynamics bug.
You can achieve this with ray sensors, with a very small range, that will restore the hitОbject dynamics, the moment just before the real collision.
I don’t know if you follow me, but I might make a blend if I have more time.