Networked input

EE has made major strides in the last week. Terrain now renders correctly over net-code. Input also works. Currently only for the keyboard. Mouse input is a matter of time.

How to use EE networked input

EE networked input utilizes named functions rather than binding directly to keys. It’s up to the client to choose which key executes a named function.

In your component that you want to handle input you must call RegisterKey. Like so:

keyboard = SceneNode.Owner.Keyboard;
keyboard.RegisterKey("Forward");

//You can also add some key event callbacks
keyboard.RegisterKey("Forward", onKeyDown, onKeyUp);

//Calling submit changes registers the keys with the client
keyboard.SubmitChanges();

Here’s an example from the editor which binds some keys for help in editing. This code should be executed on the WorldClient on the client-side.

WorldClient world = editor.scene;
world.KeyBindings.Add(OpenTK.Input.Key.W, "Forward");

Now the component can check if a key is pressed by calling

keyboard.IsKeyDown("Forward");

It is safe to call RegisterKey with the same named function multiple times. You can also use that fact to register multiple callbacks to a single key.

If you forget to call RegisterKey the key simply wont work. It needs to call this to assign it an ID in the netcode.

TODO

  • Component Editor
  • Mouse Input
  • Lighting component net-code
Leave a Reply

Your email address will not be published. Required fields are marked *