dongju.jeong Posted October 24, 2018 Posted October 24, 2018 In Unigine component system, If I want use like OnTriggerEnter(), Stay(),leave() function in Unity, should I to inherit a physical trigger node, get it as a parameter, and register callback function? and OntriggerStay () How do I use the same functionality?
silent Posted October 24, 2018 Posted October 24, 2018 Hi Dongju, Could you please explain in more details what kind of task you are trying to solve? Detect object in trigger area or something more complex? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
dongju.jeong Posted October 24, 2018 Author Posted October 24, 2018 As I am familiar with Unity's component system, I am sorry to repeat the ambiguous question. I want to provide a function to capture the overlapping moment after constructing the trigger area on the node to which the component system is applied. In my opinion, I can inherit physicalTrigger or worldTrigger as a child node and take it as a parameter and apply a callback function within the component system. Is there a simpler way ?? And is there a callback function that captures the persistent overlap of the trigger?
fox Posted October 25, 2018 Posted October 25, 2018 Hi Dongju, Unity's component system differs from UNIGINE's (this article might be useful for you, as it gives some tips on how things are organized in UNIGINE as compared to Unity). So, to have triggers functionality (capturing nodes, colliders or not, within a certain volume and firing callbacks), you don't have to add a trigger as a child to other node (as the trigger itself is a node). You can use a Physical Trigger for physical objects (with a shape and body assigned) or a World Trigger if you want to capture all nodes (colliders or not). Then you implement and set your Enter and Leave callback functions to process nodes (or only physical objects) that enter and leave the trigger area respectively. As for the Unity's OnTriggerStay(), there is no such thing in UNIGINE, but you can simply use a flag (set it to 1, when a node enters the trigger, and back to 0, when it leaves), checking this flag will tell you if a node stays inside the trigger. Don't forget to enable the touch option for the WorldTrigger, if you want to process partial overlapping between the trigger and nodes, otherwise, the trigger will react only if the whole node's bounding box will get inside and outside of it.
dongju.jeong Posted October 25, 2018 Author Posted October 25, 2018 Thank you for your help. and.. What parameters do the callback functions we assign to worldTrigger have? How do I get the information of the conflicting object?(nodePtr or Object etc.. )
fox Posted October 25, 2018 Posted October 25, 2018 You're welcome! Callback signatures for WorldTrigger are as follows: enter_callback(NodePtr node); leave_callback(NodePtr node); You can find a C++ sample illustrating WorldTrigger usage here: <UnigineSDK>/source/samples/Api/Nodes/WorldTrigger Thank you!
Recommended Posts