Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: coffeeANDsoda on September 14, 2014, 05: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?
-
Can you elaborate on your question?
-
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.
-
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?
-
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?
-
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.
-
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.
-
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?
-
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.
-
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?
-
Would I have to create a separate global event first on the player?
No.
Via int compare?
What ints?
-
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.
-
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.
-
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
-
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?
-
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?
-
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.
-
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?
-
In the suggestion there, Bool All True would be on the Trigger.
-
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.
-
In the suggestion there, Bool All True would be on the Trigger.
That is the locked door right?
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.
#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.
-
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.
-
If those bool variables are local? Because I had to make two separate variables local.
That can work.
Does that mean each key has a Set Bool FSM action or Get Bool FSM?
Sure, that can work.
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.
-
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?
-
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.
-
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?
-
Sure doesn't. It's optional.
-
Going back to the player. How would managing a bool system work on the player when theirs a state with a basic movement system?
-
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.
-
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?
-
State info?
-
State info?
Like all of actions in each of the states in the other FSM.
-
Why would you need to clone that information?
-
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?
-
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.
-
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)
-
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.
-
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?
-
#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?
#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.
-
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.
-
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.
-
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.
-
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.