feat: Velocity System [Comments Wanted]
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 249
- PR merge metrics
- No merged PRs in 30d
Description
I am going to get started on a `VelocitySystem`, it will be the same as all of the existing systems where it updates every frame. Unlike the existing component/system frameworks, **you must opt-in** by doing something like:
```
function MyCustomNode() {
Node.call(this);
this._velocityID = this.addComponent(new Velocity());
...
}
```
(Meaning if you `init` the node, the `Velocity` component will not come by default.)
There are several advantages to this approach, and it should generate very smooth velocity components. I'm thinking of using the `PhysicsEngine` and I might try to coerce it into generating the Velocities, but I'm open to other suggestions.
Then you would add logic something along the lines of:
```
MyCustomNode.prototype.onReceive = function onReceive(type, event) {
this.getVelocity().addEvent(type, event);
...
}
```
The `VelocitySystem` would take care of direction changes, pauses, increasing / decreasing speed, etc.
Please share any comments / questions / concerns.
Contributor guide
Assessment
This issue has not been assessed yet.