Skip to content

Runtime (AnimSpriteRenderComponent)

nkdtr edited this page Apr 22, 2024 · 2 revisions

First, there is two options to show sprites.

  1. A2S native component (only Win64 supported:other platforms are not tested)
  2. Using Paper2D (UnrealEngine builtin plugin for sprites->Visit here)
    Usually this is the better option.

Setting up

BP_SideViewPawn (side view) and BP_QuarterViewPawn (quarter view) are provided as samples.

  1. Attach UAnimSpriteRenderComponent to your actor
    image

  2. Setup its properties
    image
    See "Features" below for details.

  3. Set AnimSpriteSet to it
    image

Sample maps

SideView [SideViewDemo_P]

  • AWSD : move
  • Space : jump
  • P : switch character
  • L : switch lighting
    image

QuarterView [QuarterViewMap]

  • AWSD : move
  • P : switch character
    image

Features

Animation finish callback

A callback is dispatched when the animation playback is complete.
To receive callback, bind an event to OnAnimationFinished delegate.
The demo blueprint BP_SideViewPawn is a good sample of its use.
image

Auto Rotation

"AutoRotate" option of AnimSpriteRenderComponent determines the appropriate sprite "orientation" (expressed as an image index) from the Actor's orientation. It is intended to be used with Billboard materials.

QuaterViewMap is a sample of this feature.

Material(instance)s

Billboards / Quads

image

The Billboard materials (MI_AnimSprite_Billboard / MI_AnimSprite_Toon_Billboard) controls the mesh so that it always faces the camera.
This is useful when the camera is facing a variable or skewed direction.

The non-Billboard materials (MI_AnimSprite / MI_AnimSprite_Toon) controls only the size of the Quad.
This is a better fit for SideView.
The limited deformation caused by the shader makes it easier to keep the socket position consistent.

Toon Lighting / Ordinary Lighting

Toon materials (MI_AnimSprite_Toon/ MI_AnimSprite_Toon_Billboard) cannot directly obtain information about light sources other than parallel light sources, and lighting is performed through the MaterialParameterCollection (MPC_ToonLighting).
The best method for setting up light sources is likely to vary from application to application, but BP_LightFinder should serve as a sample.

For non-Toon materials (MI_AnimSprite / MI_AnimSprite_Billboard), no special precautions are required abount lighting.