Unreal Engine – Array Blueprint

Below is a simple array blueprint that you could use to create a random sequence of colours from a point light.

Simple Array Blueprint

The blueprint actor detailed in this post will allow for your character to cycle through random colors in a point light. This tutorial does require some basic understanding of blueprints to follow.

Create Blueprint Actor:

  1. Right click in a folder – Create a Blueprint and Select the ‘Actor’ Blueprint.
  2. Name accordingly.

Components:

  1. In the components section add:
    1. A point light.
    2. A static mesh (this can be a lamp or light fitting).
    3. Box Collison.
  2. Position these so they fit your requirements. Make sure your character can stand inside the trigger box.
  3. See Example below.

blueprint components

Event Graph:

  1. In the Event Graph add the code below (Enable and Disable input and Get Player controller) to activate the player controller.
    1. To add the On Component Begin Overlap node – Right Click on the Box Collision in the components tab- Select: Add Event – On Component Begin Overlap

enable input

2. Add a variable – Change it from a Boolean to a Color Actor Variable (to do this click on the default bool variable that has been added and search for color).

3. Right Click once over the Color name to convert it to an Array.

3.1 Select the Color variable and in the right hand side details panel – add 3 array elements (which will only be colors).

3.2 Change these to different colors of your choice.

Color Array

4. Drag in the Color array variable into the event graph.

5. Drag off from its only socket and search for ‘Get (a copy)’

6. Now right click in the graph and search for Random Integer.

6.1. Add 3 into the field of the Random Integer as we have 3 colors in our array (this could be higher if you use more than 3 colors)

7. Plug this into the ‘Get (a copy)’ node.

8. Drag in the point light from the components section – Drag off and search for ‘Set Light Color’ 

9. Plug in the ‘Get (a copy)’ node into New light Color socket.

10. Search for a keyboard key letter or number (e.g. E).

11. Plug this into the ‘Set Light Color’

12. Done! Now when the player character enters the collision box and presses E – the light color will change randomly to one of the inputted colors.

The Final Graph should look like the below:

If you have any questions please do get in touch or leave a comment. Thanks!

Pro Tip: Use an Interface that connects your character to any interact actions that take place through out the game/simulation. This has many advantages, as you will not need to keep adding the enable and disable input nodes and only need to add one interface node to your blueprint.

You also will be able to update the interface that will in turn update all blueprints using the interact interface.

For example see below the same code but with an interface used instead. I will create 2 or 3 posts on how to create and use an interface at some point in the near future. Please leave a comment if you would like to see these posts sooner.

Also please check the Blueprints page for further tutorials on Blueprints.

Leave a Comment

Share This Story, Choose Your Platform!

Subscribe to Newsletter

Motion Forge Pictures Blog

Featured Posts and Links

Free Height Maps

Mountain Height Map

Free 3rd Person Animations

Mountain Height Map

Free Store Downloads

Mountain Height Map

Unreal Engine - Free Materials

Mountain Height Map

Latest Posts

Categories

Tags