characterState method
Reads character's state into out without moving it; a dead
character reads as zeros, in the air.
Implementation
@override
void characterState(int character, CharacterState3D out) {
final c = characters[character];
if (c == null) {
_clearState(out);
return;
}
out.position.setFrom(c.position);
out.velocity.setFrom(c.velocity);
out.groundState = c.groundState;
out.groundBody = c.groundBody;
final ground = bodies[c.groundBody];
if (ground != null) {
out.groundNormal.setValues(0, -1, 0);
out.groundVelocity.setFrom(ground.linearVelocity);
out.groundPosition.setValues(c.position.x, ground.minY, c.position.z);
} else {
out.groundNormal.setZero();
out.groundVelocity.setZero();
out.groundPosition.setZero();
}
out.contactCount = ground == null ? 0 : 1;
}