Last active
December 5, 2020 15:43
-
-
Save sarkahn/831eebf06ed6717b3202b2450d02f826 to your computer and use it in GitHub Desktop.
ECS Input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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