Skip to content

Instantly share code, notes, and snippets.

@sarkahn
Last active December 5, 2020 15:43
Show Gist options
  • Save sarkahn/831eebf06ed6717b3202b2450d02f826 to your computer and use it in GitHub Desktop.
Save sarkahn/831eebf06ed6717b3202b2450d02f826 to your computer and use it in GitHub Desktop.
ECS Input
public class PlayerInputSystem : SystemBase
{
Controls _controls;
InputAction _moveAction;
protected override void OnCreate()
{
_controls = new Controls();
_controls.Enable();
_moveAction = _controls.Default.Move;
}
protected override void OnUpdate()
{
if (!_moveAction.triggered)
return;
float2 mov = _moveAction.ReadValue<Vector2>();
Entities
.WithAll<Player>()
.ForEach((ref Movement move) =>
{
move += mov;
}).Schedule();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment