Hi,
ok, Please find "The Ultimate Door" Prefab package
https://dl.dropboxusercontent.com/u/17356625/Unity/playmaker/misc/Door.unitypackage It follows most of your guidelines.
-- lock, lock front, lock back flags so you can create all types of locks
-- door mesh AND behavior independant, so you simply need to comply the Door requirements which are:
-- implement a DOOR / INIT to store the Door gameobject, to send back feedback on door opened and closed
-- give feedback to the Door when door is opened or closed.
-- I haven't made a runtime instanciation system, cause I don't see the uase of it, but during level development, the artist can quickly exchange the Door Object with any other compliant Doors.
I haven't added sound and light, cause that's trivial, basically, add gameobjects or fsm within the Door prefab, and respond the DOOR / OPEN, CLOSE OPENED CLOSED to trigger lights and sounds as needed.
The key to your system, and maybe what's not so obvious when you look at the various existing examples on Doors, is the colliders work and set up. For this, you need to gain some experience to understand the various issues and set up you must adopt for a clean and trouble free system:
-- DO NOT overlap triggers, check out the front, back and main trigger, they do not overlap there volumes, else triggers do not behave as expected AND from the top view you'll see that the main trigger is small in size than the front and back, because we must first know which side the user is, AND then let the main trigger do the job to open and close.
that's one way to do it, one can compute mathematically which side we are in ( I have seen and ported some implementation on the pathfinding examples if I recall right).
Also, you'll find some nice goodies, a simply event based messaging system. I haven't implemented listeners, but basically, implement "DOOR / MESSAGE" and you'll get informed when the user comes to a door but it's locked, etc etc.
As for the bubbling up events ( sending event up from a child to its parent or owner). Since it's not "yet" available in PlayMaker, the way I generally do it is to have a custom INIT system that any child who wants to send back event need to register and store the reference of the sender ( the Door ), then I simply fire events to that GameObject reference. This is clean but requires a bit of set up, that's all. Ideally, we should be able in the "send event" to choose to send events to the parents, not just the children. Maybe one day
If you have any questions on how I did things or why is it so, let me know.
Bye,
Jean