Play mode and input
Play runs the scene in the Game panel with the same rules as the shipped game. Input goes through named actions that players can rebind.
Play and stop
Play (F5) copies the open scene into a play world and runs it in the Game panel: scripts, physics, animation, audio, UI. The scene you edit is untouched; whatever happens in Play is thrown away at Stop (Shift+Esc or the toolbar button). Character controllers start at the scene's Spawn Point.
Who owns the mouse
Play starts with the cursor captured by the game, as in a shipped game. While it is captured, the game gets the mouse and every key, Esc included, so pause menus work. Two chords always reach the editor:
| Action | Chord |
|---|---|
| Stop Play | Shift+Esc |
| Free the cursor for the editor, and give it back | Shift+F1 |
A freed cursor returns to the game with a click into the Game panel. Scripts release it for menus with Game.SetCursorCaptured(false). Both chords can be rebound in Help › Keyboard Shortcuts.
Input actions
Scripts ask for actions, not keys. The project's input map (Content/Settings/Input.kinput) names actions and binds them to keys, mouse buttons, gamepad buttons and sticks; a project without one uses the defaults:
| Action | Default bindings |
|---|---|
| Move | WASD, the arrow keys, the left stick |
| Look | mouse motion |
| Jump | Space, gamepad south button |
| Sprint | Shift, left stick press |
| Crouch | C, right stick press |
| Interact | E, gamepad west button |
| Fire | left mouse button, right trigger |
Actions read in OnFixedUpdate report each press on exactly one fixed step, whatever the frame rate; read in OnUpdate, they follow the rendered frame. Contexts group bindings and can be pushed and popped (a vehicle, a menu). Players can rebind at run time with Input.Rebind and save with Input.SaveBindings. See Input.
InteractPrompt.cs
public sealed class InteractPrompt : EntityScript { protected override void OnFixedUpdate(float fixedDeltaTime) { // Actions come from the project's input map (Content/Settings/Input.kinput): // "Move" is WASD, the arrow keys and the left stick; "Interact" is E or the west button. Vector2 move = Input.GetAxis2D("Move"); if (move.LengthSquared() > 0.01f) Debug.Log($"moving {move.X:0.00}, {move.Y:0.00}"); // In OnFixedUpdate every press is reported on exactly one fixed step. if (Input.IsActionPressed("Interact")) Debug.Log("interact"); } protected override void OnUpdate(float deltaTime) { // Raw keys and the mouse are there too, for debug keys and tools. if (Input.IsKeyPressed(KeyCode.F3)) Debug.Log($"mouse at {Input.MousePosition}, moved {Input.MouseDelta}"); if (Input.IsGamepadConnected(0) && Input.IsGamepadButtonDown(GamepadButton.Start)) Debug.Log("pause"); } }
Game view options
- View › Live Game Preview In Edit keeps the Game panel rendering while you edit.
- View › Animate Characters In Edit plays animators without pressing Play.
- View › Show Editor Panels In Play keeps the panels visible while playing.
KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.