Deactivate actor using Python

Hi everyone ,
Is it possible to activate or deactivate “actor” physics option using python or logic bricks ?
thank you

For 0.3 you can disable the actual ‘actor’ physics setting at run-time.
With 0.2 or 0.3 you can disable an object’s physics though.

With Logic Bricks

Logic Editor -> Actuators -> Edit Object (Dynamics Type) -> Restore/Suspend Dynamics


Logic Editor -> Actuators -> Edit Object (Dynamics Type) -> Enable/Disable Rigid Body

With Python

import bge
cont = bge.logic.getCurrentController()
own = cont.owner

# Stop dynamics for DynamicBodies or RigidyBodies

# Stops rigid movement for RigidBodies
1 Like

Thanks for answering , I tried your method but other object’s still count the player as an actor ( i am using BGE 2.79 ) i missed to upload an image for the specific option sorry Screenshot (10)

so , could this be changed at run-time ?

and if it’s not possible , is it possible to change a property NAME at run-time ?

hi! use mask collision if you need make object ghost or stopped collision or return collisions, method mask collision work and support for bge version 2.79

Change a name no, value yes, however you can remove the existent property and add a new one, or leave the property and simply add more.

#remove a property
del own['propertyname']

#add a property or change a value of a property
own['propertyname'] = anything you like

Also, you could simply swap out the object with a new object that does not have the actor checked

do not forget to check if the object has a physics id before you suspend dynamics

if own.getPhysicsId():

Guys i ment to switch this option

i know and during runtime it’s not possible to turn it of.

You can use @RandomPerson option to disable it’s physics or use my method to change properties or to swap out the object during runtime for a new one without actor checked.

I’ll try … thank you all i appreciate it :slightly_smiling_face:

Excuse me , mmm is there’s a specific method to run your script ? i’m kinda stuck between checking if the property is replaced or not , thank you

def change_property(cont):
    own = cont.owner
    #check if property exist and if so delete it
    if 'propertyname' in own:
        del own['propertyname']
    #create or change a property    
    own['propertyname'] = any value you like  

always → python set to module → scriptname.change_property

scriptname in text editor needs to end with .py

Thank you ! Now it works fine

You can deactivate the actual physics actor for an object at run-time with UPBGE 0.3.

import bpy["Object_Name"].game.use_actor = True

Note: An API could be potentially implemented into future UPBGE 0.2x versions.
In the mean time, @Cotaks suggest to use game properties is a fine alternate solution.

1 Like

Well the api would not be implemented i’m affraid, 0.2.5 is walking on it’s last updated legs, the focus will be 0.3.0.

Not necessarily, people such as BPR and I have been pressured unofficially to take up the position of 0.2x developer… But I can totally relate to your feeling of 0.2x dying again… I don’t want to see it die anymore then you do, but I guess 0.3x is the future once performance and bugs are stable. I think I know now how 2.4x users felt about 2.5x versions. : )

@ semi-developer
I’ve been informed by one of the 0.3x developers that physics will need to be refreshed for the actual actor physics to be regonized… Even though when I tried in embedded player (but forgot to test in standalone which I will do later) it seemed to work at run-time… :man_shrugging:
So I guess for now ignore my code…

Apologies, my code appears to not even work in the slightest at all. I was merely changing the actor UI of the Blender object, not the actual object’s actor setting.

Originally, that was the whole point of having bpy and bge separated. bge was for editing the game state and bpy is for editing the blend.

I don’t understand why that line is being blurred. If people want bpy functions to work on the game state, then add them to bge…

1 Like