OK, I’m trying to add a camera with some game logic applied. I’ve got the camera and the logic I need, the only thing I’m having trouble with is figuring out how to changing values and like say modes. Like one example is, I added a game property with name,set to float ,but I can’t figure out how to set the value to like 90.
What I have
import bpy
class LogicCameras(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Logic Cameras"
bl_idname = "OBJECT_logic_cameras"
bl_space_type = 'LOGIC_EDITOR'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.label(text="180 Degree Limitation:")
row = layout.row()
row.operator("object.add_180_limit_logic_camera")
row = layout.row()
row.prop(obj, "parent", text="Parent")
class Add180LimitLogicCamera(bpy.types.Operator):
bl_idname = "object.add_180_limit_logic_camera"
bl_label = "Add 180 Camera"
def execute(self, context):
#Add Camera with Rotation (X=90 Degrees and Z=360 Degrees
bpy.ops.object.camera_add(location=(0.0, 0.0, 0.0), rotation=(1.57080, 0.0, 6.28319))
#Add Logic Sensors
bpy.ops.logic.sensor_add(type='MESSAGE', name="Look Up")
bpy.ops.logic.sensor_add(type='PROPERTY', name="If'180=True'=False")
bpy.ops.logic.sensor_add(type='PROPERTY', name="If Rotation=180")
bpy.ops.logic.sensor_add(type='MESSAGE', name="Look Down")
bpy.ops.logic.sensor_add(type='PROPERTY', name="If'0=True'=False")
bpy.ops.logic.sensor_add(type='PROPERTY', name="If Rotation=0")
#Add Logic "AND" Contollers
bpy.ops.logic.controller_add(type='LOGIC_AND', name="Look Up")
bpy.ops.logic.controller_add(type='LOGIC_AND', name="Rotation=180")
bpy.ops.logic.controller_add(type='LOGIC_AND', name="Look Down")
bpy.ops.logic.controller_add(type='LOGIC_AND', name="Rotation=0")
#Add Logic Actuators
bpy.ops.logic.actuator_add(type='MOTION', name="Rotate Up")
bpy.ops.logic.actuator_add(type='PROPERTY', name="Add to Rotation")
bpy.ops.logic.actuator_add(type='PROPERTY', name="0=True assigned to False")
bpy.ops.logic.actuator_add(type='PROPERTY', name="180=True assigned to True")
bpy.ops.logic.actuator_add(type='MOTION', name="Rotate Down")
bpy.ops.logic.actuator_add(type='PROPERTY', name="Subtract from Rotation")
bpy.ops.logic.actuator_add(type='PROPERTY', name="180=True assigned to False")
bpy.ops.logic.actuator_add(type='PROPERTY', name="0=True assigned to True")
#Add Logic Properties
bpy.ops.object.game_property_new(type='FLOAT', name="Camera_X_Rotation")
bpy.ops.object.game_property_new(type='BOOL', name="0=True")
bpy.ops.object.game_property_new(type='BOOL', name="180=True")
return {'FINISHED'}
def register():
bpy.utils.register_class(LogicCameras)
bpy.utils.register_class(Add180LimitLogicCamera)
def unregister():
bpy.utils.unregister_class(LogicCameras)
bpy.utils.unregister_class(Add180LimitLogicCamera)
if __name__ == "__main__":
register()