playMaker

Author Topic: Trigger Making a GUI  (Read 2869 times)

KurdLegend

  • Playmaker Newbie
  • *
  • Posts: 7
Trigger Making a GUI
« on: December 02, 2012, 08:25:06 PM »
Hi There,

I have a small request. In my FPS game there is a letter laying on a bench ( http://i.imgur.com/GETwN.png ). i would like the player when he enters the trigger for an Option ( for example Press I to Read The Letter ) to appear. and when the player presses I a GUI(or whatever the term is) comes up with the .png file of the Letter which can be read. ( 'I' makes the GUI disappear also ) like this http://i.imgur.com/U7HZn.png .

How can i go about doing this?

ANY help is deeply appreciated.

Thanks For Reading.

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Trigger Making a GUI
« Reply #1 on: January 05, 2013, 06:40:46 PM »
There's a sample that comes with playMaker, for opening a door with a button, I'd use (something like) that to do this.

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Trigger Making a GUI
« Reply #2 on: January 06, 2013, 10:07:32 AM »
I've done this before with things like displaying an image saying "press E to open" when you go close enough to a door..

What would work is that you make a trigger box around the letter for the area where the player can press I to read

in the first state it has a "trigger event" event waiting for the player to walk into the box - when player is in the box it will flow to state 2

in state 2 you use the "get key" action which will wait for a key to be pressed

When the key is pressed (in this case "i" ) then it will flow the next stage where you will have it set the alpha of the gui texture to 100 so its 100% visible, and listen for "i" key again

when "i" is pressed again it will flow back to the 2nd stage - setting the alpha to 0 (making it invisible) and ready for the user to press "i" and open the letter again

in both stage 2 and 3 you need to have a trigger event action that listens if the player leaves the letter area.. so if player leaves trigger then flow it back to stage 1 where it listens for the player to be in range again

to make this work you of course have to add the GUI texture to the scene first and give it a name and place it where you want it etc - and then when you start the game the letter will flow into its first state with the listener and setting alpha to 0, waiting for the player to be close enough and pressing "i" to flow into 3nd state which sets alpha to 100 and listens for "i" again to close the letter

Hope it's explained well enough - if you have any questions, feel free to ask :)
« Last Edit: January 06, 2013, 10:12:23 AM by KozTheBoss »
Remember, you don't fail unless you give up trying to succeed!

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: Trigger Making a GUI
« Reply #3 on: January 06, 2013, 12:44:57 PM »
TLDR; the GUI texture is always there - but the player switches opacity to 100 when in range and pressing "i" - making it visible. Click "i" again when in range will make it invisible again

You could always make an FSM on the GUI that tracks if it has been read or not, and then destroys itself after it's done being used so it doesn't take up memory

And thinking about it you could make it a prefab aswell i guess - make the GUI texture a prefab and use the collider that checks if player is in range to spawn it in with 0% opacity and when player presses "i" it switches between visible and invisible - when player leaves the area, the GUI texture will destroy itself :)
Remember, you don't fail unless you give up trying to succeed!