LookAt (UE)
Updated: 09/05/2024
This page contains statements regarding the alpha version.
Summary
LookAt is a function that manipulates the value of the desired parameter to follow a specific coordinate.
The coordinate to be tracked can be set via the position transform value that the actor has within the specified level.
How to handle the component
LookAt in the Cubism SDK for Unreal Engine can be used by adding a CubismLookAtComponent to child components of a CubismModel actor.
How to specify target parameters
To add a parameter for LookAt, select CubismLookAt from the “Details” tab, open “Live2D Cubism” -> “Parameters” from the list displayed at the bottom, and manually add the parameter name to “Id” in the index list that is created when a new index is inserted.
Applying parameters
CubismLookAtComponent provides individual tracking behavior for each element of Parameters
. On the basis of the blend method specified in each BlendMode
, the value in Value
is applied to the parameter corresponding to the ID set in Id
.
for (FCubismLookAtParameter& Parameter : Parameters) { if (!Parameter.bEnabled) { continue; } UCubismParameterComponent* Destination = Model->GetParameter(Parameter.Id); if (!Destination) { continue; } switch (Parameter.Axis) { case ECubismLookAtAxis::X: { Parameter.Value = Parameter.Factor * LastPosition.X; break; } case ECubismLookAtAxis::Y: { Parameter.Value = Parameter.Factor * LastPosition.Y; break; } case ECubismLookAtAxis::Z: { Parameter.Value = Parameter.Factor * LastPosition.Z; break; } } switch(Parameter.BlendMode) { case ECubismParameterBlendMode::Overwrite: { Destination->SetParameterValue(Parameter.Value); break; } case ECubismParameterBlendMode::Additive: { Destination->AddParameterValue(Parameter.Value); break; } case ECubismParameterBlendMode::Multiplicative: { Destination->MultiplyParameterValue(Parameter.Value); break; } } }
To add or remove a target parameter, add or remove the Parameters
element of the component.
Setting the coordinates to be tracked
If Enabled
is set to true, then by adding a reference to the actor to be tracked to Target
, it is possible to apply to the specified parameter a value on the basis of the actor’s position relative to the model’s origin.
If there is no actor available for reference, spawn an actor to be tracked in the level.
This behavior can be controlled by the parameters provided in CubismLookAtParameter.
- Axis
Specify which axis value of the coordinates to be tracked is referenced. - Factor
Specify the magnification of the tracking amount. The larger the value, the greater the amount of tracking for the value of the referenced coordinates. - Smoothing
Specify the smoothness of the tracking for the coordinates to be tracked.
The larger the value, the smoother the response to changes in the coordinates to be tracked.