Files
LNXSDK/leenkx/blender/lnx/logicnode/physics/LN_set_rb_velocity.py

37 lines
1.3 KiB
Python
Raw Normal View History

2025-01-22 16:18:30 +01:00
from lnx.logicnode.lnx_nodes import *
class SetVelocityNode(LnxLogicTreeNode):
"""Sets the velocity of the given rigid body."""
bl_idname = 'LNSetRigidBodyVelocityNode'
2025-01-22 16:18:30 +01:00
bl_label = 'Set RB Velocity'
lnx_section = 'props'
2025-01-22 16:18:30 +01:00
lnx_version = 1
def update_sockets(self, context):
self.inputs[2].hide = self.property0 == 'Angular'
self.inputs[3].hide = self.property0 == 'Angular'
self.inputs[4].hide = self.property0 == 'Linear'
self.inputs[5].hide = self.property0 == 'Linear'
property0: HaxeEnumProperty(
'property0',
items=[('Both', 'Both', 'Set both velocities'),
('Linear', 'Linear', 'Set only linear velocity'),
('Angular', 'Angular', 'Set only angular velocity')],
name='Velocity',
default='Both',
update=update_sockets
)
2025-01-22 16:18:30 +01:00
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxNodeSocketObject', 'RB')
self.add_input('LnxVectorSocket', 'Linear')
self.add_input('LnxBoolSocket', 'Linear On Local Axis')
2025-01-22 16:18:30 +01:00
self.add_input('LnxVectorSocket', 'Angular')
self.add_input('LnxBoolSocket', 'Angular On Local Axis')
2025-01-22 16:18:30 +01:00
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')