Input is accessed using theā¦ Input class!
public sealed class MyPlayerComponent : Component
{
protected override void OnUpdate()
{
if ( Input.Down( "jump" ) )
{
WorldPosition += Vector3.Forward * Time.Delta;
}
}
}
Here you can see that when jump is pressed down, the GameObject will move forward. We multiply forward by the time delta to make it frame rate independent.
There are a few different ways to query buttons..
Input.Down( "jump" ) // key is held down (button name is case insensitive)
Input.Pressed( "jump" ) // key was just pressed this frame
Input.Released( "jump" ) // key was just released this frame
Input.AnalogMove // joystick "move" input Vector3 (or wsad)
Input.AnalogLook // Joystick "look" input Vector3 (mouse look)
You can customize the keys for your game in the Project Settings.