Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: coffeeANDsoda on October 18, 2014, 02:49:20 AM
-
I have a object with a trigger box that I want to use in order to turn on another object for a puzzle. And with that box, I set up a trigger event to flow into Activate Game Object in another state. Here's the problem, the object I want to enable doesn't activate/turn on.
Does that mean I have to set up a colliding system that relies on a global variable? Or am I missing another state to make it work? Bare in mind the object I want to turn on has a FSM that's disabled.
-
You have to store the game object you want to enable inside a variable - then call it with another FSM, that's the only way to activate a disabled object, using playmaker. at least that's what I think I've figured out today, after much of the same issue...
the other way is to child the object and call it with another FSM in the same structure, but that could get messy organization wise
-
You have to store the game object you want to enable inside a variable - then call it with another FSM, that's the only way to activate a disabled object, using playmaker.
So would that mean I have to make another trigger plus another FSM for the boxed trigger to turn on the puzzle?
-
Just have a state in/with your trigger that stores the gameobject in a variable then activates that gameobject under your trigger events
-
Just have a state in/with your trigger that stores the gameobject in a variable then activates that gameobject under your trigger events
To make sure, when I create the variable inside that FSM, do I set the Variable Type to GameObject? Because I tried making it a global variable with the object itself and it doesn't work.
-
Also, this is what I don't understand. Correct me if I'm wrong, but why would I need to store a variable collider in trigger event, and then use Activate Game Object? Because wouldn't creating a variable(global or local) with the object included be doing the same thing?
-
Drag the Game Object directly into the Activate Game Object action since you're working with scene objects.
Or you could use a variable (it doesn't matter if you do it either way), just create one and drag the game object into there instead, then specify that variable on the Activate Game Object action. And yes, of course it would need to be a Game Object variable since you're dealing with a Game Object.
To activate the FSM you need to use Enable Behavior and drag the FSM script from the inspector into that slot.
-
To activate the FSM you need to use Enable Behavior and drag the FSM script from the inspector into that slot.
But on two separate states right? Just to make sure, cause I don't see how it would work on just one whole state.
-
There's nothing wrong with using two, if that works.
-
I don't understand how I could enable a light as well as a custom shader. But this is what I have during gameplay.
(https://db.tt/KsVjbBqF)
-
To activate the FSM you need to use Enable Behavior and drag the FSM script from the inspector into that slot.
Would work best on the state having Activate Game Object action? Or the Enable Behavior action being on the Button FSM that is disabled at the moment?
Plus I left out that I want to use two more buttons in order to make the box trigger turn all of them on. Because I thought I would kind of keep the puzzle simple and turn on all three buttons regardless of what order they are in.
By the way , isn't there a way to script a simple glowing shader in Unity indie? So each button glows when you turn them on.
-
For the glow you could try adding an alpha mask with a faded circle as a 2d texture. Have you tried looking on the asset store for a shader for Unity free?
-
For the glow you could try adding an alpha mask with a faded circle as a 2d texture.
Alpha mask being a action? I had in mind of creating shaders by myself since I already made my own meshes and textures.
-
well there's actually a lot of info about writing unity shaders on the web from what I've seen, but I'm really not sure you'll get an answer about shaders here, i know i can't help you with that.
-
I see. As for alpha mask what do you mean? I looked in actions in playmaker and shaders and I can't find it.
-
Explaining alpha masks would be a completely separate material creation thing and not a playmaker thing, at least now how I'm suggesting it.
Google is your friend. http://forum.unity3d.com/threads/glow-effect-in-free-version-unity.78093/
-
I see but I think what I'm trying to explain is simply turning on another shader or just switch the basic shader it has right now to a different one. So the picture that I posted would be the result when the player triggers a event that turns on the button.
-
Drag the Game Object directly into the Activate Game Object action since you're working with scene objects.
Didn't work with or without a variable. I got somewhere with Enable Behaviour action, but how would that work with three buttons?
-
Still an issue? Not sure what methods you tried, a dirty but effective way would be starting the object as activated, have it set it's own name with "Get Owner", then have it de-activate itself, then use the name variable to activate it later. Just make sure you uncheck reset on disable otherwise it will reset and keep running that same function.
-
Still an issue? Not sure what methods you tried, a dirty but effective way would be starting the object as activated, have it set it's own name with "Get Owner", then have it de-activate itself, then use the name variable to activate it later. Just make sure you uncheck reset on disable otherwise it will reset and keep running that same function.
It's a simple puzzle though, it's only going up to a trigger(the control deck) enabling three buttons so when all of them are pressed(only set up like a OnTriggerStay) then a door is destroyed. How would that work?
-
Sounds like a design question? where are you stuck exactly?
-
Sounds like a design question? where are you stuck exactly?
Having the control deck object FSM being able to activate all three buttons when Enable Behaviour only activates one object FSM.
-
Just use it multiple times, use more variables if you have to...
-
As for triggering all three buttons to destroy or unlock the door, how would that be done?
-
have an fsm track three bool variables, when all are true (each button has been set to 'true') then you can use "activate object" and make the door dissapear (activate object is used to also de-activate them), or you can destroy it with destroy gameobject which is actually a slight bump in resources.
You can also add a sound. If you want to. To animate the door is a whole other thing you would want to google.
-
have an fsm track three bool variables, when all are true (each button has been set to 'true') then you can use "activate object" and make the door dissapear (activate object is used to also de-activate them), or you can destroy it with destroy gameobject which is actually a slight bump in resources.
So if I want to stick with a "tracking bool variable" approach, would that mean that I would have to add a action called that? Or would I have to add a few more actions onto each trigger button fsm before I make each variable(suspecting you mean local vars)?
You can also add a sound. If you want to. To animate the door is a whole other thing you would want to google.
I did mess around with simple door turning animation in another prototype awhile back, but it is something I will look into. I had an idea to alter or add empty object/point to the camera so a mini cutscene would appear, don't know how to do that though.
-
You can track the buttons however you want. But either way you will need to have each button trigger a variable update. Where you actually calculate that for the door opening doesn't matter as long as an FSM somewhere is doing the logic. For clicking on the buttons you can use "bool flip" that way if they click it again the bool goes back to false... the action "bool all true" will do the logic for you.
-
You can track the buttons however you want. But either way you will need to have each button trigger a variable update. Where you actually calculate that for the door opening doesn't matter as long as an FSM somewhere is doing the logic. For clicking on the buttons you can use "bool flip" that way if they click it again the bool goes back to false... the action "bool all true" will do the logic for you.
So that would mean for the buttons they would have to use bool flip for each before making them local variables? If so, then that would mean when I would add the action bool all true before adding animation or destorying the door? Since bool all true would have to be added to the FSM on the door right?
-
with your variables it just depends on how you plan to use them
FSMs can exist on any object, have you watched the tutorial video on managers? You can create FSMs whose sole function is to remotely do logic like this. It really doesn't matter where/when you are defining these variables as long as both the variables and the "all true" function are all running and available when they need to be.
That's also what "every frame" is for, so in the case of bool "all true" it will keep checking until all are true. Don't restrict yourself to thinking too linearly! You could do this in a lot of different ways.
-
To double check, what you mentioned had to do with global variables? Therefore all three global variables would be objects that aren't empty? If so, is it necessary to make the buttons prefabs?
-
You don't necessarily have to use global variables. You can use "get fsm gameobject" or "get FSM bool" to get variables from another FSM. you just choose the object, the FSM, and then the variable
with "get FSM ___" you can then store variables in your fsm doing the logic
-
You can use "get fsm gameobject" or "get FSM bool" to get variables from another FSM. you just choose the object, the FSM, and then the variable
with "get FSM ___" you can then store variables in your fsm doing the logic
Regardless of how many times I can add those actions to a state? If that's the case, I will try that out for the gate.
-
I'm not exactly sure what you're asking, but if we're talking about bools then your logic FSM will have to listen for updates from the other objects, because an FSM that uses "get fsm" only has the most recent data from the last time I went and "got" the variable.
-
I'm not exactly sure what you're asking,
Simply adding the same action over and over again since you can't add more than one object to a "get FSM bool" action if I'm not mistaken.
-
Yes that works, you could build strings but that's probably overkill for something like this.
-
Going back on topic to the closed gate FSM, I made three local gameobject variables, and when I play, press on all three buttons, the gate still doesn't destroy itself.
-
Also, does it matter if the Gate is the trigger or is it required to have another object parented to destroy it?
-
As long as you can tell playmaker to destroy an object that exists in the scene, it doesn't matter where the FSM is attached. Although it's probably less resource intensive to just de-activate it.
-
As long as you can tell playmaker to destroy an object that exists in the scene, it doesn't matter where the FSM is attached. Although it's probably less resource intensive to just de-activate it.
De-activate the gate? How would that be done if I just simply use a "Destroy Self" action on the gates FSM?
-
What else do I need to add to this state in order to make it transition to the last state?
https://db.tt/j72E46z4
-
What do you need the button gameobjects for? I see you're getting the gameobjects and setting them in that FSM, but why? What are you going to do with those game objects stored in the FSM?
The only reason you'd do that is if you want that FSM to *do something* to that game object. Like de-activate it, move it, etc.
How are you triggering your buttons? First you need something that triggers your button is pressed/clicked on/stepped on, whatever. Either using a raycast trigger or something. Then however you are triggering that button as "clicked/turned on/set to true", then you would send that variable (like boolean=true) into a logic FSM that checks if all the buttons have been clicked.
From what I can tell you're getting the FSM gameobject but you don't have a plan as to why?
Really all you need is a way to track your button triggers and some way to activate them (and that can be done in probably a lot of ways), check if they're all true, then de-activate or destroy the gate.
-
I just realized maybe the answer to your question is way simpler than I thought... Do you mean how do you get the state to move on? I assume you already know you can use "finished" transition as the default moving from 1 state to the next once actions are complete...?
-
What do you need the button gameobjects for? I see you're getting the gameobjects and setting them in that FSM, but why? What are you going to do with those game objects stored in the FSM?
The only reason you'd do that is if you want that FSM to *do something* to that game object. Like de-activate it, move it, etc.
Correct me if I'm wrong, but didn't you tell me earlier that I could add "Get Fsm Game Object" to the gate in order to make all three buttons destroy it without having to add any more actions to all three buttons? Bare in mind button local 1-3 are set up to be "local variables" that are game objects.
-
How you have it set up now, you could have the gate destroy the buttons, see? If you want the buttons to destroy the gate, all you have to do is the reverse. You could do this so many ways, I would suggest a simple solution but I don't know how you are doing the button trigger logic.
It's better to keep everything in one place, wherever your buttons are doing their logic to open the gate, you should probably have that same FSM get the gate object, then destroy it when your logic determines the gate should be destroyed.
-
Quick overhead view of the puzzle.
(https://db.tt/OjP2S8zd)
And then the button FSM data.
https://db.tt/w0tvmd9T
https://db.tt/AKJi4n4k
I do plan to remove exit state because the buttons don't need a combination, they only only need to be pressed once.
-
Well it looks like you're most of the way there. You're only missing is the variables and logic to determine when all the buttons are pressed.
What you need to do is create 3 bool variables, try creating 3 global bools, name them "button1" "button2" "button3", default is false and that's good.
Now when your player goes into the "enter" state use the action 'bool flip' on the variable regarding each button. So after the player steps on a button it's bool is 'flipped' from false to true. Since it's being flipped, if it's stepped on again it will do it again, I've never actually used colliders like this before so hopefully if you exit it doesn't trigger the flip AGAIN and set it as false (if it does, try just using 'bool set value' as true which is the check mark in that set value action)
Then I suggest you put in the gate as a start action a listener "all true" that waits for all three button globals to return "true". when it does, have it go to a new state which uses either "destroy object" or "activate object" (unchecked means it de-activate) and use it on "owner" since it's on the gate, it will perform the action on the owner of that action which is the gate.
-
Then I suggest you put in the gate as a start action a listener "all true" that waits for all three button globals to return "true". when it does, have it go to a new state which uses either "destroy object" or "activate object" (unchecked means it de-activate) and use it on "owner" since it's on the gate, it will perform the action on the owner of that action which is the gate.
Just to double check, do you mean I need to add "bool all true" at the Gate's FSM's starting state? Or the state that the "Start" global transitions it's on?
-
It really doesn't matter as long it's checking those bools every frame and the state with "bool all true" is always active (when it needs to be, to check the bool values)
if it's on the start state but then your FSM goes to another state, it won't matter where it is because you won't be checking for those bools anymore.
so when you run it, just make sure the state with "bool all true" is green and checking every frame. that way when everything is finally all true it runs the next states you specify.
-
Added bool all true to the gate FSM, made three globals for each button and added bool flip, now it works. Thanks. Pretty soon, I will probably upload a sample of the game but haven't figured out how to end a level and transition to another.
-
Nice!
I believe loading levels is used with "load level" action. The level name is the same as the scene in your assets folder (levels are in fact, the same scene files that you've been saving). You also need to include all scene files in your build, which you can do from the Build Settings menu
-
Nice!
I believe loading levels is used with "load level" action. The level name is the same as the scene in your assets folder (levels are in fact, the same scene files that you've been saving). You also need to include all scene files in your build, which you can do from the Build Settings menu
Would that mean that "load level" would be added to the players FSM? Or would that require a global variable and global transition system on a empty object?
-
Hey coffeeAndsoda,
sorry for the late reply. It sounds like you're a little confused about how FSMs work. An FSM is just like a script, it's simply a set of instructions. For the most part, it doesn't matter what object an FSM is placed on.
Object-specific FSMs are only most important if you're using something like "Get Owner" or you are using objects with specific layers or tags. Unity does use some basic tags and layers such as "main camera" and "player". But largely FSMs are simply like scripts, they can be used in any way, at any time, with or for any object - all depending on how you code it.
Now to answer your question, all you have to do is use load level under the circumstances you decide. Whether the player enters a trigger, collects an item, solves a puzzle, whatever, at whatever point you want your logic to say "load level", that's when you use load level. It doesn't matter what object the FSM is on.
This is true for most the questions you've been asking, it doesn't matter what object an FSM is on. Remember, the only thing that matters is the set of instructions your FSM has. An FSM on an object can communicate with any other FSM in your level, any FSM can do anything you want to anything you want - it all depends on how you code it!
edit: you should watch the Huttong tutorial on "managers" this will probably help you on things like this.
-
I see. Well this is what I have so far for the game. The second level's puzzle unlocks by itself, so I thought about designing another puzzle instead.
https://dl.dropboxusercontent.com/u/75323608/Puzzle%20Playmaker%20plaformer/Puzzle%20Simple%20Playmaker%20Example.html
-
Nice! Can't figure out how to rotate my character/camera...
-
Nice! Can't figure out how to rotate my character/camera...
It's a pretty basic camera. What do I do to add in order to set up a camera that auto adjusts so items don't block it?
-
Try changing the camera clip distance on the camera.
-
Try changing the camera clip distance on the camera.
You mean Clipping Planes? Because when I do that it doesn't really solve the problem of the camera being blocked by walls.