forked from LeenkxTeam/LNXSDK
added checkbox to enable on called on any object on has contact and on on contact nodes so users has less work to do to make to trigger on any object
This commit is contained in:
@ -1,5 +1,16 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
def toggle_second_input(self, context):
|
||||
"""Show/hide the second input socket based on the 'On Any Object' checkbox"""
|
||||
if self.property0: # "On Any Object" is enabled
|
||||
# Hide the second input socket
|
||||
if len(self.inputs) > 1:
|
||||
self.inputs.remove(self.inputs.values()[-1])
|
||||
else: # "On Any Object" is disabled
|
||||
# Show the second input socket if it doesn't exist
|
||||
if len(self.inputs) == 1:
|
||||
self.add_input('LnxNodeSocketObject', 'RB 2')
|
||||
|
||||
class HasContactNode(LnxLogicTreeNode):
|
||||
"""Returns whether the given rigid body has contact with another given rigid body."""
|
||||
bl_idname = 'LNHasContactNode'
|
||||
@ -7,8 +18,18 @@ class HasContactNode(LnxLogicTreeNode):
|
||||
lnx_section = 'contact'
|
||||
lnx_version = 1
|
||||
|
||||
property0: HaxeBoolProperty(
|
||||
'property0',
|
||||
name='On Any Object',
|
||||
description='If enabled, returns true if the rigid body has contact with any object',
|
||||
default=False,
|
||||
update=toggle_second_input)
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketObject', 'RB 1')
|
||||
self.add_input('LnxNodeSocketObject', 'RB 2')
|
||||
|
||||
self.add_output('LnxBoolSocket', 'Has Contact')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0') # "On Any Object" checkbox
|
||||
|
||||
Reference in New Issue
Block a user