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.property1: # "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 OnContactNode(LnxLogicTreeNode):
|
||||
"""Activates the output when the rigid body make contact with
|
||||
another rigid body.
|
||||
@ -23,6 +34,13 @@ class OnContactNode(LnxLogicTreeNode):
|
||||
('end', 'End', 'The contact between the rigid bodies ends')],
|
||||
name='', default='begin')
|
||||
|
||||
property1: HaxeBoolProperty(
|
||||
'property1',
|
||||
name='On Any Object',
|
||||
description='If enabled, triggers on contact with any object instead of a specific object',
|
||||
default=False,
|
||||
update=toggle_second_input)
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketObject', 'RB 1')
|
||||
self.add_input('LnxNodeSocketObject', 'RB 2')
|
||||
@ -31,3 +49,4 @@ class OnContactNode(LnxLogicTreeNode):
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0')
|
||||
layout.prop(self, 'property1') # "On Any Object" checkbox
|
||||
|
||||
Reference in New Issue
Block a user