Class CharacterBody
A character model, animated: the clips of its CharacterAnimationSet blended in a PlayableGraph by what the character is doing, at the speed it is really doing it, and the figure set where it belongs (its soles on the ground, its seat on its seat, its head over the waves). The one body behind every character in the game (CharacterAnimationController) and the World Sim walker.
public sealed class CharacterBody : IDisposable
- Inheritance
-
CharacterBody
- Implements
- Inherited Members
Remarks
A graph, not an AnimatorController. One mixer holds every whole-body state (standing, walking, running, the air, crouching, treading, the two strokes, climbing, sitting, the roll, the death), its weights eased toward the state's and always summing to one. An arms-only layer over it plays the punches, the cast and the guard, so a cast thrown walking keeps the legs walking. There is no controller asset to keep in step with parameters.
Speed-matched. Under the walk clip's own speed idle fades into walk; between walk and run the two are blended with their strides locked to one phase; past the run clip's speed the run plays faster. The strokes play at the swim's pace and the climb is stepped by the height climbed.
In the water as a swimmer is (SwimPose): the movement floats the capsule on still water, so at the surface the figure is set by its head, held just over the drawn sea, riding and tipping with each wave, and it swims head up; only under the surface does it lie flat along its swim.
Client only in use: the server never builds one (the controller's body is compiled out of a server build).
Fields
CapsuleHeight
The capsule height the swim float line is measured against (every playable prefab's).
public const float CapsuleHeight = 1.6
Field Value
Properties
IsDead
Lying dead (its last pose held).
public bool IsDead { get; }
Property Value
KeyedSeatHeight
The seat height its seated clip fits, metres, on this model (the set's, scaled to the model's height).
public float KeyedSeatHeight { get; }
Property Value
Lift
The figure's height over its capsule's feet, metres (the swell it rides, the ground it finds).
public float Lift { get; }
Property Value
RestHeight
The model's height standing at rest, metres.
public float RestHeight { get; }
Property Value
SurfaceShare
1 floating at the surface, 0 well under it (or not swimming).
public float SurfaceShare { get; }
Property Value
Methods
AirShares(float, out float, out float, out float)
How a body in the air splits between rising, the top and coming down, by its vertical speed (m/s).
public static void AirShares(float verticalSpeed, out float up, out float top, out float down)
Parameters
Cast()
Casts: both hands gather and thrust.
public void Cast()
Create(Animator, CharacterAnimationSet, string)
Animates animator (a model with a Humanoid avatar) with set, or returns null
(and says why) when it cannot: no avatar, not a humanoid, no idle.
public static CharacterBody Create(Animator animator, CharacterAnimationSet set, string owner)
Parameters
animatorAnimatorsetCharacterAnimationSetownerstring
Returns
Die(bool)
Dies: falls and lies. already lies at once, for a character that was dead before this client saw
it (a corpse walked up to, a reconnect).
public void Die(bool already = false)
Parameters
alreadybool
Dispose()
public void Dispose()
Gait(float, float, float, out float, out float, out float, out float)
How a ground speed splits between idle, walk and run, and how fast the run plays: idle into walk under the walk clip's own speed, walk into run up to the run clip's, then the run faster (to FishMMO.Shared.CharacterBody.MaxRunRate).
public static void Gait(float speed, float walkSpeed, float runSpeed, out float idle, out float walk, out float run, out float rate)
Parameters
Place(float)
Sets the figure where it belongs, after the animation has posed it: its feet on the ground, its seat on its seat, its head over the waves. Call after the animation updates (LateUpdate).
public void Place(float deltaTime)
Parameters
deltaTimefloat
Remarks
On land, placing the model by its bind pose is not enough: a humanoid clip keeps the hip height of the body it was captured on, the capsule hovers its skin width above what it stands on, and on a slope the capsule's lowest point is above the ground under its middle. So the lower of the two soles is found against the ground beneath it and the body eased up or down to meet it, while the figure is on screen. Sat on the ground the soles are on it too, and the same search seats it; on a seat it is raised or lowered by the seat's height against the one the clip was keyed for. In the air it holds where it was, so a landing does not pop.
In the water the capsule floats on the still surface. At the surface the figure is set by its head instead: the head joint held HeadAboveWater over the drawn sea, so the water stands at its chin whether it treads or leans into its stroke, it heaves with every wave, and it tips with the wave's slope. Going under, it eases back onto the capsule, which the controller steers.
Pose(in CharacterMotion, float)
One frame of the character's motion: picks and blends the clips. Call before the animation updates (Update).
public void Pose(in CharacterMotion motion, float deltaTime)
Parameters
motionCharacterMotiondeltaTimefloat
Punch()
Throws a punch, the right and the left by turns (not while the hands are busy swimming, climbing or sitting).
public void Punch()
RestExtent(Transform, out float, out float)
The lowest and highest world height of a figure at rest: each mesh's own bounds (its vertices as modelled), placed by its renderer's transform. Never the renderers' bounds: the importer sizes a skinned renderer's bounds to hold every clip in its file (arms overhead, a roll, lying dead).
public static bool RestExtent(Transform shape, out float bottom, out float top)
Parameters
Returns
Revive()
Rises again (revived, or a death that was mispredicted).
public void Revive()
Roll()
Rolls forward once.
public void Roll()
SetBlocking(bool)
Raises the guard, or lowers it.
public void SetBlocking(bool block)
Parameters
blockbool
SetPlaying(bool)
The graph runs, or stops (a hidden character's), with the GameObject.
public void SetPlaying(bool playing)
Parameters
playingbool
Settle()
Stood still where it was put down, so a jump across the map does not arrive running.
public void Settle()
SitDown(bool, float, float)
Sits down where it stands: on the ground, or, with seat, on a seat that high (metres over its
feet) whose front edge is back metres behind it (its back already turned to it).
public void SitDown(bool seat, float height, float back)
Parameters
StandUp()
Gets up again (at the sit's pace, from wherever the sit has got to).
public void StandUp()