Is there a way to freeze an object in blender?
Here?s why I think my script gets into an infinite loop:
When I change the "oxigenio"'s attribute, the GE detects another collision, because it "thinks" "oxigenio" is another object, so it changes the atribute again...and so on..and so on...still, i really need to have this attributes within the object...
import Blender
import GameLogic
#get actuator
collision_actuator = GameLogic.getCurrentController().getActuator("wall_x_act")
#get object's velocity components
vx = Blender.Object.Get("oxigenio").getProperty("vx").getData()
vy = Blender.Object.Get("oxigenio").getProperty("vy").getData()
vz = Blender.Object.Get("oxigenio").getProperty("vz").getData()
#change object's vx
Blender.Object.Get("oxigenio").getProperty("vx").setData(-vx)
#change vx component
collision_actuator.setLinearVelocity(-vx,vy,vz,False)
GameLogic.addActiveActuator(collision_actuator,True)
i?ve tried to solve this using a decorator, but it?s not working:
import Blender
import GameEngine
def locked(meth):
meth.locked = False
def wrapper(*args, **kwargs):
if meth.locked:
return
meth.locked = True
ret = meth(*args, **kwargs)
meth.locked = False
return ret
return wrapper
@locked
def collision_handler():
#get actuator
collision_actuator = GameLogic.getCurrentController().getActuator("wall_x_act")
#get object's velocity components
vx = Blender.Object.Get("oxigenio").getProperty("vx").getData()
vy = Blender.Object.Get("oxigenio").getProperty("vy").getData()
vz = Blender.Object.Get("oxigenio").getProperty("vz").getData()
#change object's vx
Blender.Object.Get("oxigenio").getProperty("vx").setData(-vx)
#change vx component
collision_actuator.setLinearVelocity(-vx,vy,vz,False)
GameLogic.addActiveActuator(collision_actuator,True)
collision_handler()
Can the GE solve this problem in some way?
Do I have to include an atribute "locked" in the objects attributes, so that it can?t collide twice with the same wall?
please post a link if you know where i can find more information..i?ve searched everywhere...
thanks in advance