eugene.litvinov Posted February 14, 2011 Share Posted February 14, 2011 Maybe has ability to get trigger pointer when calls trigger's enter/leave callbacks? I want next: We have some count of triggers: each of they determine some set of properties for areas, that this triggers described. So, if player enter to trigger's area, then callback is called, and I must read and apply some set of properties. But, in callback I can't get trigger pointer to get his properties. It can be done, only if I use void setEnterCallback(string name,variable arg0,variable arg1) and then I can pass trigger pointer to my callbacks. But this is not convenience, cause this callbacks can not be set through Editor, it's can be done only through script. We can describe this properties in some special node (not in trigger), but how bind this special node with trigger or trigger's area? Link to comment
frustum Posted February 14, 2011 Share Posted February 14, 2011 Editor callbacks have 2 default arguments. The first one is external node. The second one is our trigger. Link to comment
eugene.litvinov Posted February 15, 2011 Author Share Posted February 15, 2011 Ok, thanks. I will be great, if in manual will written typical callbacks with default parameters, for example for PhysicalTrigger::setEnterCallback is: void enterCallback(Body body, PhysicalTrigger trigger) { } Link to comment
binstream Posted February 16, 2011 Share Posted February 16, 2011 PhysicalTrigger Class is fully documented, while the editor customization isn't a common case so it isn't in the library. Link to comment
eugene.litvinov Posted February 16, 2011 Author Share Posted February 16, 2011 I have some new problem... :mellow: I need detect, when PlayerActor cross trigger. I use triggers for determine indoors and outdoors spaces in game. I have flag in my Player class - and I want to change it. When PlayeActor instance enter trigger, in callback i try next: void eventEnterCallback(Body body, PhysicalTrigger trigger) { Object object = body.getObject(); Property prop = object.getProperty(); if (prop != NULL) log.message("Property: " + prop.getName() + "\n"); log.message("Is Player: " + is_base_class("Player", object) + "\n"); log.message("typeof Player: " + typeof(object) + "\n"); log.message("getTypeName Player: " + object.getTypeName() + "\n"); } I have next log: 12:04:00 Is Player: 0 12:04:00 typeof Player: Object 12:04:00 getTypeName Player: ObjectDummy So trigger body refer to some ObjectDummy (maybe PlayerActor inner node), and I can not determine that is PlayerActor and can not get PlayerActor property, that I set for it during initialization; How it can be done, or it is some another pattern to do this? Thanks Link to comment
frustum Posted February 22, 2011 Share Posted February 22, 2011 PhysicalTrigger doesn't detect any node related classes. WorldTrigger can do that. You can get Body from your PlayerActor and check it in the PhysicalTrigger callback. Link to comment
eugene.litvinov Posted February 22, 2011 Author Share Posted February 22, 2011 We try to use WorldTrigger, but it have not trigger type (Cylinder, Sphere, Box, ets.) - and we need describe non-rectangular areas. For determine PlayerActor in trigger I use next: void eventEnterCallback(Body body, PhysicalTrigger trigger) { PlayerActor actor = body.getObject(); log.message("--------------------------\n"); log.message("actor typeinfo: " + typeinfo(actor) + "\n"); log.message("actor is_base_class: " + is_base_class("PlayerActor", actor) + "\n"); log.message("body.getName(): " + body.getName() + "\n"); // I set Body body = actor.getBody(); body.setName("actor_body"); in actor initialization } This do next log: 5:31:11 --------------------------15:31:11 actor typeinfo: Object 000000000D7C8790 external (82:21:21) 15:31:11 actor is_base_class: 0 15:31:11 body.getName(): actor_body So I can determine body name, but can't determine PlayerActor class ( Link to comment
Recommended Posts