Dev Blog
Profile picture

Written by Jose Vasquez

developer based in sydney and random digital artist, tango god flamenco dancer hobbyist.

Unreal Tutorial beach Ball

Posted: November 01, 2020

Before you begin you should check out these videos on the basics of the unreal editor and blue print basics

  1. Create project and Ball Blueprint

create a new project based on the 3rd person template, also make sure the starter content is installed.

  1. Create Project

install the starter content when creating project, create a project based on the blueprint 3rd person or the top down view.

  • create blueprint name it beachball or what ever you like.
  • open the blue print and go to the component section add a Projectile Movement Component
  • Add a static mesh component and give it a mesh
  • since update 4.3 the root component cannot be a Scene component or an Arrow component
  • Change settings projectile movement component
  • Initial speed to 200.0
  • Change velocity on the x to -1.0 leave the others at 0
  • Change static mesh component settings make it movable
  • Check simulate physics
  • Change collision presets to custom make sure overlap events is checked and overlap with pawn.
  1. Spawn Balls

To spawn the balls will use the level blueprint. First in the level editor we need to add a reference point for where we want to spawn the beachball

  • In the mode taps select basic scroll down and either use a target point or note actor and place somewhere at the top of the stair case.

  • Grab an event begin play node

  • Grab a set timer function node set time to 3 and looping to true

  • Create a function named SpawnDeathBalls

  • Now later on we want to stop the balls spawning so create a bool variable named Spawn and set to true. Go inside the function and create a branch node

  • Create a spawnActor node that spawns the beachball blueprint

  • Get reference to the target point from the level

  • Get the actor transform and connect it to spawnactor spawn transform input

  • Back in the event graph type in the name of the function for the set timer function simulate if all went well the beachballs will spawn after 3 seconds continuously. Lets change the scale as it cannot be done through the components section

  • Inside the function grab the return value output and drag to event graph and type set actor relative scale 3D to create node. Connect set Actor relative Scale 3d and change to 2.5 across x,y,z "you might need to change the initial speed back in the projectile component"
  1. Collision with player

Open up the beach ball blueprint event graph

  • Grab an event actor begin overlap
  • Cast to pawn, grab get play pawn node and use object equal to and connection to branch as condition
  • Grab an apply damage node and connect the return value from get player pawn to the damaged actor input.
  • Open up the character event graph
  • Grab event any damage node
  • Connect to print string and type in hit then test.
  • disable the player and restart the level will use a quick fix
  • grab a disable input node and connect target to self reference variable
  • grab a delay node set duration to 2 and an open level node enter the name of the map your in test
  1. Trigger Panel

I used the SM_CornerFrame mesh as an indicator and parent but you can use any static mesh you want.

  • Go to the mode tab and from basic select box trigger, drag and drop.
  • Change brush settings x=128,y=256,z=256
  • In the scene outliner drag and drop the trigger volume into the static mesh
  • In the modes tab type in text and select text render drag into the scene on the trigger volume
  • Change text "press e to stop beach balls"
  • Change world size
  • Rotate if need
  1. Set up trigger events

  • Select the trigger volume and grab a onactorbeginoverlap and the onactorendoverlap nodes.
  • Connect the output to an equal(object) node and compare with get player pawn
  • Create a new bool variable named overlap
  • Crate two branch node and connect output of equal(object) to the condition of the branch or the on actor begin and on actor end events.
  • Then use a set node for the overlap variable to set It to true when the player is overlapping the trigger volume and false when leaving the trigger volume
  1. Set up user input

  • Get a E input node
  • Connect to a branch node and connect the condition input to a reference of the overlap bool variable.
  • Connect the true output to a set node that points to the spawn bool variable and set it to false.
  • test the balls should stop spawning when press e while in the trigger.
  1. Kill balls

make the balls destroy them selves all actors have a life span that controls this, you can create a trigger and destroy when the ball enters but this how im going to do it is similar to the old beach ball tutorial

  • open up beachball blueprint and go to the construction script
  • grab a set life span function node that targets self and enter a lifespan
  • life span function will destroy the actor automatically after the period of time entered.

test and that's it folks!

Exercises

  • show congratulation text to player when he reaches the top

  • turn the trigger into a component

  • randomise the life span of the balls

  • spawn different sizes of balls

  • change ball speed at spawn and over time.