EyeBlink (UE)

Updated: 09/05/2024

This page contains statements regarding the alpha version.

Summary

EyeBlink is a function that applies an open/close state value to the current value of the parameter for eye blinking.
Click here for information on how to set eye blink parameters for your model.

The parameters for eye blinking can be set in the model itself or specified as desired by the user in Unreal Engine.

How to handle the component

EyeBlink in the Cubism SDK for Unreal Engine can be used by adding a CubismEyeBlinkComponent to child components of a CubismModel actor.

If the parameter for eye blinking is set in .model3.json, the default automatic eye-blinking behavior is applied, so no configuration on the user side is required.

How to add target parameters

If the parameters for eye blinking are set in .model3.json, CubismEyeBlinkComponent will be automatically added as a child component to the CubismModel actor upon importing. If you want to manually add parameters to EyeBlink, select CubismEyeBlink from the “Details” tab, open “Live2D Cubism” -> “Ids” from the list displayed at the bottom, and manually rewrite the names of the specified parameters or insert new indexes and manually write parameter names.

Applying parameters

CubismEyeBlinkComponent applies the value in Value uniformly to all parameters corresponding to the IDs set in Ids on the basis of the blend method specified in BlendMode.

for (FString Id : Ids)
{
	UCubismParameterComponent* Destination = Model->GetParameter(Id);

	if (!Destination)
	{
		continue;
	}

	switch (BlendMode)
	{
		case ECubismParameterBlendMode::Overwrite:
		{
			Destination->SetParameterValue(Value);
			break;
		}
		case ECubismParameterBlendMode::Additive:
		{
			Destination->AddParameterValue(Value);
			break;
		}
		case ECubismParameterBlendMode::Multiplicative:
		{
			Destination->MultiplyParameterValue(Value);
			break;
		}
	}
}

To add or remove a parameter for eye blinking, add or remove the ID of the parameter in Ids of the component.

Manually manipulating values

If AutoEnabled is set to false, the value of Value can be manipulated externally to apply any user-specified value to all the specified parameters at once.

Automatically manipulating values

If AutoEnabled is set to true, a value that acts like eye blinking is automatically applied. This behavior can be controlled by the parameters provided in CubismEyeBlinkComponent.

  • Mean
    Specify the average interval at which to blink.
  • MaximumDeviation
    Specify the fluctuation range from the average interval at which to blink.
StartTime = Mean + FMath::FRandRange(-MaximumDeviation, MaximumDeviation);
  • TimeScale
    Specify the time scale of the behavior. Increasing the value makes the behavior quicker, and decreasing the value makes the behavior slower.
  • ClosingPeriod
    Specify the time taken to close the eyes.
const float t = TimeScale * (Time - StartTime) / ClosingPeriod;
NewValue = 1.0f - t;
  • ClosedPeriod
    Specify the time during which the eyes are closed.
const float t = TimeScale * (Time - StartTime) / ClosedPeriod;
NewValue = 0.0f;
  • OpeningPeriod
    Specify the time taken to open the eyes.
const float t = TimeScale * (Time - StartTime) / OpeningPeriod;
NewValue = t;
Was this article helpful?
YesNo
Please let us know what you think about this article.