playMaker

Author Topic: Pushable button to trigger event  (Read 1403 times)

kemil88

  • Playmaker Newbie
  • *
  • Posts: 4
Pushable button to trigger event
« on: October 13, 2019, 04:29:12 AM »
Hello, I want to let the player be able to push a button to open doors/anything else, for example, in the first Scene of the game, the player is inside a closed Room, there's a hidden button that has to be pushed, once the player pushes it, a door opens and the player can continue, at the end of the scene, there's a book, once the player interact by pressing "e", the next scene is loaded.

So, here is what I tought to do:

First button, State, wait for input Get Button ("Interact") (I did add this to the preferences, so it should work), then next state, push move the button (transform? but I want it to slowly move, do I have to use an animation or there's a way to move it and not just teleport it to new position?), and same thing for the door that will move up (it's a stone door in a dungeon).

Book that loads the next scene, State, wait for input (same as above), then next state, load scene at index additive 1 (next scene I guess?).

Now, my questions are 2:

1) How do I make a transition event that waits for input to be recieved? I know I can do it with actions but it doesn't wait it, it just DOES it... I saw the transition events currently available and there's one with mouse, I mean, I could do it with mouse, but since it's also the button I use to shoot, it could be a problem (since I will also use this for many things like to open doors).

2) Is it possible to slowly move objects and not just change their position?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pushable button to trigger event
« Reply #1 on: October 13, 2019, 05:41:41 AM »
Hi.
If you want to 'Animate' it to move from A to B you could use Vector 3 Interpolate Action (or Float Interpolate Action if only in x,y or z direction)
or you can use the Beta Tween actions

Get button down has an event. if you want the button only to work when the player is at a certain location, you can use Colliders (Set a triggers) and use trigger event actions.

kemil88

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Pushable button to trigger event
« Reply #2 on: October 13, 2019, 08:14:35 AM »
I try with Add Transition > System Events and I can't find anything related to Input Get Button (I can find it in Actios, but not on events), now I am trying to understand how to move with float events (since yes, it's only XYZ movement) but I don't understand how to select the destination of the animation (I'm using Animate Float action)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pushable button to trigger event
« Reply #3 on: October 14, 2019, 02:23:04 PM »
Hi.
You need the 'Get Button Down' action.

To move you can use 'Vector 3 Interpolate' action

kemil88

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Pushable button to trigger event
« Reply #4 on: October 15, 2019, 03:59:34 AM »
Okay, then maybe I did not understand how actions work. I tought an action was automatically used once the state is reached (for example, I get to a state that have "action > Imput Get Button Down) and the action will act as if I did press that button, but I did not), so, this is what I'm thinking to do.

Start > State1 on collision Stay (so that if you leave the collision, you can't?) > State 2 on mouse Stay > State 3 Action ImputGetButtonDown Interact (name of my E button) Finish > State 4 Vector 3 Interpolate Action (to move the button back) State 5 Load Scene (scene index +1)

So, the gameObject that works as a pushable button, can be pushed back only if you are facing it in close range, and you can push the E button push it back and load next scene, right?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pushable button to trigger event
« Reply #5 on: October 15, 2019, 10:28:08 AM »
Hi.
There are many actions that will wait for something,


i'm not sure why you need the on mouse stay, you want the mouse to click on the button?

the way you could do this =

on Start State :
Have a trigger event (the Collider Component must be set as trigger)
Set Trigger enter or Trigger Stay and Transition a event to state two (call the event 'In Range' for example)

State 2 :
if you want to use a button, place a 'Get Button Down' action and make a transition to state 3 (call it 'Button Pressed')
if you want to use a key, then place a 'Get Key Down' action and do the same transition.
if you want to use a Mouse Click, then Place a 'Mouse Pick Event' Action and do the same transition.
If you want multiple ways, you can place all 3 the actions (or 2 of them).

Then also add another 'Trigger Event' and check for 'On Exit' and set a Transition event back to the Start State.

State 3 :
Vector 3 Interpolate (or Tween)

State 4 :
Load Scene