Advanced Tutorial 3: Have something move to a Desired Location When You Press a Button

From The Endless Mission Wiki
Jump to: navigation, search

Below is a tutorial detailing how to move something to a desired location when you press a button. It will go over how to use the "InputGetKey" script, the "SingleMove" script, and how to use them together to produce the desired behavior.

The InputGetKey Script[edit | edit source]

This section will show a simple implementation of the "InputGetKey" script. You can apply the method in this section to trigger any Endless Event on any button down you want. If you do not have a project you are currently working in, open up "Barebones Game" in the Editor.

  1. Start by Right-Clicking on "Gameplay" in the project hierarchy, and select "Create Empty". Rename this empty entity "Button Press Entity". This will be Entity that you attach the script to. In order for you to have a script do something in your project, you always will need an Entity to attach it to.
  2. Search for "InputGetKey" in the Library with the "Endless" tab selected. Drag the script "InputGetKey" from the Library onto "Button Press Entity".
  3. For this example, we are just going to make you win the game if you press "p".
  4. Press the "+" button beneath "On Button Down ()" Endless Event on the "InputGetKey" script you just added.
  5. Drag "GameplayLogic" from your Project Hierarchy onto where it says "No Target" beneath "On Button Down ()". Choose "PlayerWon()" from the dropdown that says "No Function"
  6. Finally change the "Key Name" variable on "InputGetKey" to "p" (without the quotes). You can put any key here really.4
  7. Play the scene, and press "p". You will see that you will win the game by pressing whatever key you put in the "Key Name" field.

The SingleMove Script[edit | edit source]

This section of the Wiki will detail how to move an object from point A to point B using the "SingleMove" script. If you have completed "The InputGetKey Script," you can do this all in the same scene. You may also start from scratch by opening "Barebones Game" in the editor.

  1. Right-Click on "Gameplay" in your Project Hierarchy and select "Create Empty" from the dropdown that appears. Rename this entity to "Moving Object".
  2. Drag an object you want to move automatically onto "Moving Object" from the Library. For this tutorial, we will be moving "Racer Light Visuals"

Combining InputGetKey and Single Move To Move An Object on a Button Press[edit | edit source]

Possible Applications[edit | edit source]