Timeline for Entity Component System - Handling Input
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 3, 2017 at 16:59 | comment | added | Bryan Robertson | Yeah except ideally you want a layer in between that, in my view. You don't want to going directly from input to a physics component like that. It's more like input -> (translation layer that translates input data into "player intentions") -> (character controller layer that acts on "player intentions", and doesn't care whether or not they came from an input device) -> 'physics component' | |
May 3, 2017 at 16:30 | comment | added | Rich. T. | This all sounds great - thanks for the advice. So the input system would detect a key press and add the desired movement to a 'physics' component, and then a physics system would try to resolve the movement. Does that sound right? | |
May 3, 2017 at 16:28 | vote | accept | Rich. T. | ||
May 3, 2017 at 12:59 | comment | added | Naros |
To add to Bryan's answer, you'd still accept the movement request with W and apply a linear movement force. The physics system will attempt to move the character based on this movement force and if possible will do so. If it cannot, a collision will be detected and the character won't be moved. It is here that you can raise an event or some other notification means allowing your ECS environment to deal with other collision responses dynamically, like play a sound because they're hitting a wall, etc.
|
|
May 3, 2017 at 10:31 | comment | added | darkside | This is essentially what I came here to say. +1 | |
May 3, 2017 at 5:32 | history | answered | Bryan Robertson | CC BY-SA 3.0 |