How can you create a foreground parallax effect in UE5?

Hello,

I am currently a Master’s student in Game Direction, and I am working with my group on a 2D platformer mini-game.

I was wondering if it would be possible to create a foreground parallax effect, meaning adding layers of elements between the camera and the player in order to produce a sense of depth, similar to games like Hollow Knight, but using Unreal Engine 5.

Would anyone have an idea of how to proceed or any suggestions on how to implement this?

Thank you in advance for your help!

Hi There,

Definetely doable, but there is no already integrated tool around it, you need to create one.

What you need to make a ParallaxManager.This manager simply attaches to your camera.

You need to create let’s say 1 background layer and 1 foreground (You can increase decrease), this can be just quads with nice UV.

You create a material for this background and foreground layers.

LayerPosition = CameraPosition * ParallaxFactor , parallax factor is basically your depth. The smaller it is the slower it moves. More far away objects should have a smaller depth.

On your actor, create a dynamic material instance and pass your position (vector) to the material on tick. Now on your material you can get Position.X with Panner node or Offset UV to manipulate the position of the image on your material. If you have multiple layers, you can mask images and add them together will still do multiple layers work without additional quads.

  • your camera moves 10cm
    -Layer 2 : 10x0.1= 1cm // your background
    -Layer 1 : 10x0.5 = 5cm // your background
    -Layer0 : 10x1.5 = 15cm // your foreground

So now you have simple effect of parallax. The thing is to repeating the pattern so when you move continiously, it creates the illusion of a big space.

A similar approach is available here.