Perspective/Interface

2.5D Platformer game



Use 3rd person template:
in its character BP, set cameraboom setting as :
rotation as world, untick use pawn control rotation
image.png
In event graph, only keep below graph:
image.png
To let character face towards camera when turning, change camera 180 degree rotation in BP,
Then rotate the playerstart in scene 180 too (or else the left right move button by A,D key be swapped)
image.png

also change character movement to make speed of turning more snappy,
increase rotation rate from 500 to 720
image.png
also tick Constrain to plane (to not let character slide along z axis when interact on other object)
set constraint normal y axis value as 1 (then character can still slide on object, just not on z axis)
image.png
gravity set to 3, jump velocity 1200cm/s, max walk speed 800cm/s
image.png

Create a BP actor, called CameraManager
cut from 3rd charcter BP, and Paste the spring arm and camera component in the camera BP , add following variable
image.png
tick the follow 2
image.png

Set Camera actor BP (or else camera view is limited if using 3rd person BP camera component, which has to bound with the character)


Make actor spawn on the camera:

In 3rd character event graph, add event begin with:
image.png

Make camera follow character left/right:


In Cameramanager BP, create a fucntion called UpdateCameraPos
graph as below
(VInterp to node is to smoothly update position, instead of just snap to it)
image.png
event tick:
image.png

Disable Do collision test in spring arm
(not let camera view get into the character some times, but will let front ground object block character view.
Solution: either not make any frontground object in the game, or make custom collision channel to only do collision test with those frontground object. )
image.png

Make camera won’t follow character up and down (jump):


Revise the Update camera pos function graph:
image.png

To make height lock toggle on and off easily (add select node and boolean lock height):
image.png
Tick lock height default value to decide if height is locked

Promote variable of interp speed too instead of just using 5 (change to 7, make camera follow less lag)

Add camera offset:

(let character not in middle of screen but have an offset to update, 0ff set value determine how fast the camera move for offset, I set 50 instead of 150 to fit my scene):
image.png

To fix camera zoom out problem when offset, split + and x nodes and only connect x and z
image.png
image.png


Add Enemy/obstacle:


Create BP character, called BP_Enemy
Add a sphere, set collison to no collision
image.png
rescale capsule size to match the sphere
image.png
Set event tick node below,
reduce walk speed from character movement to 30cm/s, tick Constranit to plane, Y axis 1.0
image.png
image.png

To let character destroy the enemy after step on (now just character bounce back when he steps on it):
Open 3rd character BP, click on function (Override) box, choose On Landed
image.png
image.png



Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.