UE4 mobile afterimage
The previous project used a function of moving afterimages, and the core component is the PoseableMesh component. The specific effect is as follows:
Next, the implementation logic is introduced.
material
The afterimage material needs special treatment:
After creating a material, the specific settings are as follows:
Editor node:
The Fresnel function is mainly used, and exponenth is set as a parameter for external calls.
Afterimage Actor
Afterimage is essentially an Actor. Create an actor class. This article creates a Ghost class.
Add the PoseableMesh component to it
. Click the component. The details panel of the component is set as shown in the figure:
mainly the skeletal mesh of the character to be filled with afterimage. Because the component gets the pose by capturing the animation.
The main logic is as follows:
first, create the material instance of the material created before the material, and then assign the material to the skeletal mesh of PoseableMesh.
Then get the owner (the reference of the player will be set as the owner when the ghost is generated), convert it to the player class, get the player's mesh, call the created copy pose from skeleton component node to capture the current player's animation pose, and the last step is to
set The parameters of the material, linearize the exponenth from 1 to 0, to achieve the effect of the generated afterimage slowly disappearing, through the timeline, and then destroy the actor:
player logic
The player part is mainly the Actor that generates the ghost regularly.
Be careful to pass your own reference to the owner.
Finally, the afterimage effect is achieved.