playMaker

Author Topic: Modular Door Prefab  (Read 4654 times)

digimbyte

  • Junior Playmaker
  • **
  • Posts: 52
Modular Door Prefab
« on: March 14, 2013, 10:12:52 PM »
Hey guys
I've been messing around with a few things and I thought making a door prefab to use in almost any game

please bare with me,
Basically, a trigger on front and back and a logic bool for either side to lock/unlock each side or have the door disabled
if door is disabled, lights are off and trigger function does nothing
if trigger entered door must open, wait, then check to see if player left, if not, wait again and loop

I have all that setup
the problem is I'd prefer the trigger unlock/lock on the root of the prefab but i don't think there is anyway around it other then having a trigger with an FSM
which adds an INT value to the root

but i can foresee problems and bugs if i simply add and subtract INT values, so Bool's would be more ideal
« Last Edit: March 14, 2013, 10:14:40 PM by digimbyte »

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Modular Door Prefab
« Reply #1 on: March 15, 2013, 01:56:55 PM »
Hello,

I am unsure to be honest what do you mean by having an int variable to subtract or add to it.
You can create the entire FSM for lock/unlock and disable all without using any variables at all.

You can create a trigger in front of the door for instance and create a FSM on the trigger with "Trigger Event" actions which don't need any variables at all.

If what I said didn't help much, could you please explain further what you want to do exactly?

Hope that helps.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Modular Door Prefab
« Reply #2 on: March 15, 2013, 02:22:46 PM »
I'm confused on what you're asking about.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Red

  • Hero Member
  • *****
  • Posts: 563
Re: Modular Door Prefab
« Reply #3 on: March 15, 2013, 02:44:03 PM »
I'm not 100% certain of what you mean but i'll see if i can grasp it.

Are you asking as to whether there is a way to have the unlocking system on the root object itself (as in, having the FSM system on the root) instead of the colliders? then yes... and if you're in need of a system to communicate between these objects, with the "get child/get parent" actions you can thread them together pretty well so that they know where to fire off events and for using the get/set fsm actions.

though, i'm not sure of this but if you want to have the triggers being the root objects, you might want to consider making an empty game object that has the collider that you want to use be the root object and have the mesh object be a child of that object (since objects can't have more than one collider on them, you would not want to sacrifice the model's collider since what good is a door if a player can just walk through it as if it weren't there?)

Is this helpful? if you need more information, maybe break down what you're hoping to accomplish. making a universal system is incredibly easy with playmaker with the right setup... hell, the AI system i'm working on now is pretty much drag-n-drop ready as long as the appropriate layers are set up in the project... so, modularity is definitely something you can achieve with Playmaker.

digimbyte

  • Junior Playmaker
  • **
  • Posts: 52
Re: Modular Door Prefab
« Reply #4 on: March 22, 2013, 06:47:57 PM »
Maybe I should upload the project, and you guys can take a look at the door and seeing what I'm doing wrong?

I want it to be modular so i can add door switches and panels and even timed clocks as a map designer would see fit

once its done i hope to include it as a standard package for playmaker


the Setup is this

>Door Root holds everything
>Door Pivot is where the mesh spawns and anything attached to the "Door" is
>Front and back triggers to detect if person is standing there to open door
(this leaves room for optional switch in Bool's to open door)
>Lights Need to listen to the Door's Bools and change accordingly to being 'off' 'unlocked' or 'locked'

front and back need to work independently as the map developer may want it to be a one way door or simply lock one side


The problem I'm having
>setting the lights if they are on/off and disabled
>Sending the trigger events so they open the door and wait until the player has left that side

jay.pis

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Modular Door Prefab
« Reply #5 on: March 22, 2013, 09:06:49 PM »
Quote
The problem I'm having
>setting the lights if they are on/off and disabled

Do the lights go on when someone enters the door and off once the person leaves?

Quote
>Sending the trigger events so they open the door and wait until the player has left that side

Which is "that" side?

Most of what you're wanting to do can be done with triggers and adding in switches to open/close doors then you'll need to add an fsm to another object, the switch panel to control the door.

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Modular Door Prefab
« Reply #6 on: March 22, 2013, 09:08:20 PM »
Anychance you havent seen the standard PlayMaker Example projects... Check "No Exit"... its nothing BUT doors... doors, doors and more doors...
Your work is done!

M

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Modular Door Prefab
« Reply #7 on: May 11, 2013, 08:32:22 AM »
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