Author Topic: Press "E" for Use on an gameObject  (Read 308 times)


  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Press "E" for Use on an gameObject
« on: August 10, 2018, 12:04:31 PM »
I wanted the Key "E" to be pressed for action/use mecanism.

For example, I have a cube I want if the player is at the cube and pressing E then a function is called (save game or open door and so on).

How to achieve that?

I spend 3 hours without a result...


  • Beta Group
  • Hero Member
  • *
  • Posts: 930
    • View Profile
    • Fat Pug Studio
Re: Press "E" for Use on an gameObject
« Reply #1 on: August 10, 2018, 02:24:19 PM »
You can either get distance from the cube every frame and when it's under defined threshold, pressing E will start the next event - saving game for example. Or you can put a cube with only transform and trigger collider and start the event on trigger stay.


  • Administrator
  • Hero Member
  • *****
  • Posts: 4034
    • View Profile
    • jinxtergames
Re: Press "E" for Use on an gameObject
« Reply #2 on: August 11, 2018, 08:26:20 PM »
For doors :
Place an object that has a collider @the door position .
Set the collider component as trigger.
And you can edit the trigger to resize it.

Place an fsm on the object and in the 1st state use a 'trigger event' and set 'on trigger stay'
Set an event to the next state.

In the next state place another 'trigger event' and set 'on trigger exit'
Set an event to the 1st state.

Also place a 'Get Key Down' and set a event to a 3rd state.

There you can then use actions to close/open the door.

Then loop back to the 2nd event.

For thing like save you can simply use the 'Get Key Down' action.