Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: coffeeANDsoda on September 14, 2014, 02:58:20 PM

Title: Simple door unlocking system issues. [SOLVED]
Post by: coffeeANDsoda on September 14, 2014, 02:58:20 PM
Here's the problem. I have a issue understanding the tutorial below because not only it's brief, but how would that apply to just picking up two items and going up to a trigger cube that acts as a lock?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 16, 2014, 12:38:40 PM
Can you elaborate on your question?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 16, 2014, 01:34:50 PM
Can you elaborate on your question?

I want to create an unlockable door that doesn't require pressing a button in first person and doesn't display text confirming it. So the lock is a object with collision that disappears after it's unlocked.

Therefore the player needs to simply pick up two objects and collide with the lock object that is a trigger.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 16, 2014, 01:43:38 PM
Just flip a bool to True for each item you pick up and use Bool All True to see if the items have been picked up when he touches the trigger.

Make sense?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 16, 2014, 02:14:10 PM
Just flip a bool to True for each item you pick up and use Bool All True to see if the items have been picked up when he touches the trigger.

Make sense?

Meaning that the action "Bool flip's" variable is global for both of the pickup items? Plus would that mean Bool All True would go to the door trigger?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 18, 2014, 04:35:48 PM
Doesn't work. This is what I have for the fsm's on both the key and the Door Mananger.

The key FSM
First state has a trigger event action
(On TriggerEnter, Send event set up with a event with a gameobject variable)

Second state has the following actions.
#1 Send event with the event target set to self
#2 Get parent use owner with the same gameobject variable
#3 Destroy Object with same variable as previously, with detach children on.(The fsm is attached to a box that is parented with the key and a empty object)
#4 Bool flip with the global being a bool.

And the DoorManager fsm includes the following states..

#1 wait action with a transitional event

and the second state just has a Bool All True with an event flowing back into the first state as well as the same global bool variable stored in Store Result.



Title: Re: Simple door unlocking system issues.
Post by: Lane on September 18, 2014, 05:09:36 PM
Err, I don't really understand what you would do it that way for.

When you pick up the items, they must change some bool to True, it makes absolutely no difference where this information is at, just that you can get to it. Easiest way is to just stick it on the player since he's the one entering the trigger.

Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

If that happens every time the player enters the trigger then you have a fantastic gate system that can decide if the door should open or not. Very simple.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 18, 2014, 08:02:02 PM
When you pick up the items, they must change some bool to True, it makes absolutely no difference where this information is at, just that you can get to it. Easiest way is to just stick it on the player since he's the one entering the trigger.

So I need to add a separate fsm for the player in order to add bool actions?

Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

Therefore, I add both of those actions in one state?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 19, 2014, 07:38:41 AM
Add it in your item management FSM, its probably on your player, right? It just needs to be somewhere accessible to the trigger so that when you enter the trigger it goes into a state where it tries to find those bool's, obviously you can instantly store the thing that collided with the trigger (the player) so its convenient to have it on the player.

You could do the check in one state, should work fine. If its happening too fast then split it into two states: one getting the bools and the other comparing them.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 19, 2014, 01:14:11 PM
Add it in your item management FSM, its probably on your player, right?


No.

It just needs to be somewhere accessible to the trigger so that when you enter the trigger it goes into a state where it tries to find those bool's, obviously you can instantly store the thing that collided with the trigger (the player) so its convenient to have it on the player.

Would I have to create a separate global event first on the player?


You could do the check in one state, should work fine. If its happening too fast then split it into two states: one getting the bools and the other comparing them.

Via int compare?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 19, 2014, 01:20:59 PM
Would I have to create a separate global event first on the player?

No.

Quote
Via int compare?

What ints?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 19, 2014, 01:32:40 PM


What ints?

Wouldn't that help though? What I don't understand what action can I use in order to compare those bools. Because I can't find a action that does that.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 19, 2014, 02:17:24 PM
Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

Bool All True.

Meaning the player has both keys, if both aren't true then don't fire any event, the trigger would do nothing. If both are true then open the door.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 19, 2014, 03:12:24 PM
Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

Bool All True.

Meaning the player has both keys, if both aren't true then don't fire any event, the trigger would do nothing. If both are true then open the door.

I find this kind of confusing because I'm not sure whether or not it is required to use global variables or not. However, I have these pics for reference.

https://db.tt/eQ1sVJCJ

https://db.tt/gr1ZsQ0h

https://db.tt/5wDSBLW8

https://db.tt/2XDmp7vR

https://db.tt/GLOKcz1R

https://db.tt/LjNiIutz
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 19, 2014, 03:24:13 PM
Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

Bool All True.

Meaning the player has both keys, if both aren't true then don't fire any event, the trigger would do nothing. If both are true then open the door.

I find this kind of confusing because I'm not sure whether or not it is required to use global variables or not. However, I have these pics for reference.

You can do it with or without globals. Your implementation looks different from what I was suggesting. You aren't even specifying any bools to check in the Bool All True action?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 22, 2014, 04:16:11 PM

You can do it with or without globals. Your implementation looks different from what I was suggesting. You aren't even specifying any bools to check in the Bool All True action?

How would it be done without globals?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 22, 2014, 04:26:36 PM
When you pick up the items, they must change some bool to True, it makes absolutely no difference where this information is at, just that you can get to it. Easiest way is to just stick it on the player since he's the one entering the trigger.

Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

If that happens every time the player enters the trigger then you have a fantastic gate system that can decide if the door should open or not. Very simple.

Like that.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 23, 2014, 12:36:35 AM
When you pick up the items, they must change some bool to True, it makes absolutely no difference where this information is at, just that you can get to it. Easiest way is to just stick it on the player since he's the one entering the trigger.

For starters, does that mean I can use bool all true in the same fsm?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 23, 2014, 03:50:24 AM
In the suggestion there, Bool All True would be on the Trigger.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 23, 2014, 10:19:53 PM
In the suggestion there, Bool All True would be on the Trigger.

That is the locked door right?

Now that you're getting a bool true on the player, when he enters the trigger just make the trigger Get Fsm Bool on all of the bools you need and do a Bool All True action to see if they're true or not.

This is another element to the whole door puzzle that I have a difficult time wrapping my head around.

#1 Does that mean I create two local bool variables that are true?

#2 What about the keys/objects since they have the standard trigger event, send event, get parent, destroy actions that a regular pickup item would have.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 24, 2014, 03:56:07 AM
In the suggestion there, Bool All True would be on the Trigger.

That is the locked door right?

Quote
This is another element to the whole door puzzle that I have a difficult time wrapping my head around.

#1 Does that mean I create two local bool variables that are true?

They start as false. If you do have the key, they should be true.

Quote
#2 What about the keys/objects since they have the standard trigger event, send event, get parent, destroy actions that a regular pickup item would have.

I don't know what you mean here. The only thing that needs to happen is very simple:

Create a bool for each key you need.
When the item is picked up, change the bool to true.
When you touch the trigger, check the bools that are required to unlock the door.
If they're all true then you must have all of the keys, so continue opening the door.
If any are false then the door does not open.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 24, 2014, 02:36:54 PM
They start as false. If you do have the key, they should be true.

If those bool variables are local? Because I had to make two separate variables local.

Create a bool for each key you need.
When the item is picked up, change the bool to true.

Does that mean each key has a Set Bool FSM action or Get Bool FSM?


When you touch the trigger, check the bools that are required to unlock the door.
If they're all true then you must have all of the keys, so continue opening the door.
If any are false then the door does not open.

With Get Fsm Bool and Bool All True? Regardless of my key setup, when the player collides with the trigger it disappears.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 24, 2014, 02:59:31 PM
If those bool variables are local? Because I had to make two separate variables local.

That can work.

Quote
Does that mean each key has a Set Bool FSM action or Get Bool FSM?

Sure, that can work.

Quote
With Get Fsm Bool and Bool All True? Regardless of my key setup, when the player collides with the trigger it disappears.

You're on the right track, tweak it until it works. Figure out what isn't working and try stuff until it does. Experimentation is the best way to learn.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 25, 2014, 10:46:26 PM

Does that mean each key has a Set Bool FSM action or Get Bool FSM?

Sure, that can work.

For the action Set FSM Bool, when you set up game object button is there a difference between Use Owner and Specify? Since we are talking about a FSM for the keys. Plus how would that be different from using Get Fsm Bool?

Title: Re: Simple door unlocking system issues.
Post by: Lane on September 26, 2014, 07:21:05 AM
Set fsm bool would change the property of the target bool. Owner as default will target the gameobject that the current fsm is on. Specify would let you target something else.

Get fsm bool will get the bool from some other fsm and store it in a local variable.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 27, 2014, 11:58:32 PM
I see. For the door I have a trigger event, and it has a Store Colllider option. Does it matter if it is set to None?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 28, 2014, 07:21:43 AM
Sure doesn't. It's optional.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 28, 2014, 05:27:40 PM
Going back to the player. How would managing a bool system work on the player when theirs a state with a basic movement system?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 28, 2014, 06:19:27 PM
You don't have to manage the bools locally on the player, other FSM's can access those variables and change them remotely.

Otherwise, you could just put another FSM on the Player.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 28, 2014, 07:04:34 PM
You don't have to manage the bools locally on the player, other FSM's can access those variables and change them remotely.

Otherwise, you could just put another FSM on the Player.

And this second FSM attached to the player would have the same 'state' info as the door?
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 28, 2014, 07:44:39 PM
State info?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 28, 2014, 07:50:32 PM
State info?

Like all of actions in each of the states in the other FSM.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 29, 2014, 04:00:23 AM
Why would you need to clone that information?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 29, 2014, 12:02:31 PM
Why would you need to clone that information?

Isn't that what you meant earlier though? To add standard bool actions to the player inorder for the door to be locked everytime it goes up to one without keys?
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 29, 2014, 10:31:44 PM
Also, if I'm not mistaken, you did mention to add a get fsm bool action on the key right? In the variable name section, I can't access the local variables in that fsm.
Title: Re: Simple door unlocking system issues.
Post by: Lane on September 30, 2014, 04:40:56 AM
Here, this is how it works, download the attached .unitypackage.

You probably need the 4.6b17 release to import the package.

(http://dl.dropboxusercontent.com/u/38606641/2DUnity/keys2.gif)
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on September 30, 2014, 12:25:32 PM
Here, this is how it works, download the attached .unitypackage.

You probably need the 4.6b17 release to import the package.

(http://dl.dropboxusercontent.com/u/38606641/2DUnity/keys2.gif)

Can it load all the FSMs? Because I'm on unity version 4.2.2 and I already have quite a few projects saved in it.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on October 06, 2014, 05:07:24 PM
Hello again, I have two questions about learning from the example that you gave me.

#1 What should I do if I don't use a material indicating whether or not it's opened?

#2 How would picking up an item work for the object being parented? Because the last time I checked my project, the keys are parented and it used Destroy Object compared to your example? Should I just use one object altogether and add a separate FSM for simple itween animation?
Title: Re: Simple door unlocking system issues.
Post by: Lane on October 06, 2014, 09:20:01 PM
Quote
#1 What should I do if I don't use a material indicating whether or not it's opened?

What stops you from doing anything you want instead?

Quote
#2 How would picking up an item work for the object being parented? Because the last time I checked my project, the keys are parented and it used Destroy Object compared to your example? Should I just use one object altogether and add a separate FSM for simple itween animation?

I'm not sure what you mean here, probably something specific to your project? Likely just a matter of destroying the parent instead of the object with the fsm. Basic stuff you need to integrate in your project.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on October 06, 2014, 09:50:18 PM
I'm not sure what you mean here

Your example applied only to a single object instead of a parented object. Or adding a box collider to the object verses a mesh collider. Don't really see how I could get animation to work with the key data all at the same time.
Title: Re: Simple door unlocking system issues.
Post by: Lane on October 07, 2014, 07:45:49 AM
When the trigger executes you just have to do whatever else you want it to do. If you don't want it to destroy immediately but instead run an animation then just use the appropriate actions to accomplish that and get rid of the destroy action. You have full flexibility, don't be shy about adding or removing things to experiment as that is the best way to learn.
Title: Re: Simple door unlocking system issues.
Post by: colpolstudios on October 09, 2014, 01:46:06 PM
Hi, I hope you don`t mind me jumping in, but from the video this is an excellent example.

I have a play maker template where you can choose if the player needs a key to open the door.

The need key bool can be set within the inspector to false or true.

True "you need a key to access"

False "no key needed"

To be honest I don`t know if you can share templates.

let me know if this kind of help would be useful.

I am not around much lately, but will check on a reply when I can.
Title: Re: Simple door unlocking system issues.
Post by: coffeeANDsoda on October 17, 2014, 06:48:31 PM
When the trigger executes you just have to do whatever else you want it to do. If you don't want it to destroy immediately but instead run an animation then just use the appropriate actions to accomplish that and get rid of the destroy action. You have full flexibility, don't be shy about adding or removing things to experiment as that is the best way to learn.

I see. Even though I'm running on Unity 4.2, I managed to look at the example file you uploaded, added the needed global variables, actions, etc , and got it to work. Thanks for your help.