Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: dbsrb43 on January 18, 2013, 08:34:10 AM

Title: Destroy blocks when walked on??
Post by: dbsrb43 on January 18, 2013, 08:34:10 AM
http://www.gameshot.org/?id=3733
I need to make a scene like this where the cube will be deleted when i walked or stepped on it...
I'm not an advanced playmaker developer.
I'm developing for mobile, so it needs to be smooth...
Need a detailed description thanks!!!
Title: Re: Destroy blocks when walked on??
Post by: Vallar on January 19, 2013, 02:51:38 AM
That is actually a pretty nice game.

Well to be honest, I believe this is all a trigger setup much like the video here [u=" Trigger Tutorial[/u]. You will just make use of the On Trigger Enter and On Trigger Exit parameters.

To explain more:

Legend -----> Bold = actions, Italic = parameters in actions, Underlined = Events, Double Quotes (" ") = States.


1- Create the object that you want to act as the blocks.
2- Assign a trigger to it.
3- Change that to a prefab.
4- Add an FSM to the trigger of the object.
5- The FSM would have a Trigger Event action.
6- Create 2 events, one called Enter and one called Exit
7- Create 2 states, one called "Enter" and one called "Exit"
8- Change the parameter Send Event in the Trigger Event to the event you created Enter.
9- Create another Trigger Event action and change the Trigger to On Trigger Exit
10- Change the parameter Send Event in the Trigger Event to the event you created Exit.
11- In the "Enter" state create an action to change the texture of the platform by using action Set Material Texture
12- In the "Exit" state create an action to destroy the object by first using action Get Parent (and store it in an object variable) so that we can get the parent and not only destroy the trigger and then use Destroy Object and feed it the object variable we created

Hope that helps.
Title: Re: Destroy blocks when walked on??
Post by: dbsrb43 on January 19, 2013, 04:34:37 AM
Thanks, didn't thought about that!
BTW, u know how to generate random blocks? like in the game "line runner"?
seems really simple, but i don't have knowledge for those>
it will be nice if u can link me to the project like this (for unity)
or some codes??
Playmaker possible??
Title: Re: Destroy blocks when walked on??
Post by: Vallar on January 19, 2013, 05:30:00 AM
You are most welcome.

I am not sure what is Line Runner, I am sorry. However generating random blocks can be done in Playmaker as well.

It is the same as the previous setup however you will create a block add the states to it as stated previously, then create another one and assign the states to it as said previously as well and so on for all the blocks that you want.
Now you will create an Empty Game Object that one you can call Block Manager for instance.
Inside that Block Manager you would create an Int minValue variable, an Int maxValue variable and an Int currentValue.
Add a Random Int action and assign to the Minimum Value parameter to minValue and the Maximum Value paramter maxValue and store the result in currentValue.
Then you would have another action called Int Compare and you would have it compare the currentValue value against the various values there is to create a random cube.

So basically the logic would go like this:
1- You create 5 blocks as prefabs with their states.
2- You create the Block Manager object and assign the previous state to it.
3- Create inside the Block Manager object 5 different states (Ideally named Block1, Block2, ..., Block5)
5- Using the state that has the Int Compare, you compare against the value of each block and one the currentValue is equal to the value of that Block, you send the event for that Block to be created.

That is however to create random blocks, how Line Runner does it however, I am not sure, I haven't played the game and I am afraid I can't at the moment check it out. If that wasn't helpful enough, let me know I will look into it later for you.


Hope that helps in anyway.
Title: Re: Destroy blocks when walked on??
Post by: brendang on January 19, 2013, 08:06:48 AM
Just tapping in to thank Vallaras well.  When someone takes the time to lay out such a terrific explanation, it helps everyone learn a bit more.   Go community!
Title: Re: Destroy blocks when walked on??
Post by: Vallar on January 19, 2013, 08:52:11 AM
Thank you very much, Brendang. I guess we are all in the same shoes here; trying to figure out our way.