In our Programming class, we had one week to script a block that attacked the player, we needed to show the indication of the block as an enemy before it attacked.
The scripting application I used was Unreal Engine 4's Blueprint visual scripting. The block is a hand painted texture and made out of a simple default 256x256 cube in unreal units. The triangles are parented meshes to the cube.
This is the Actor Blueprint, In this post, I will be briefly be breaking down its contents.
The main animation was done in the timeline using vector coordinates, There is an initial shake and then fall. Then I set the actor relative location which updates as the event track plays.
Camera shake was added on an event track, as well as an audio queue for extra impact.
Dynamic materials are swapped at the base of the block and animated with transitions from yellow to red. These are warning indication that the block is about to come down.
Set relative Scale 3D was used for the shadow, as the block falls, there is a shadow that widens to create a better illusion of Z access depth. The shadow was made by a simple primitive being squashed down with a grey emissive material
I wanted to then explore the possibilities of Vector parameters. I set up a function where it would randomize the initial color of the block bottom before it came down! I used a "random float in range node". I broke these into XYZ coordinates which would translate into RGB. I used these clamps to set a random color value within the vector parameter instance.
The difficulty with this was getting the dynamic material to reset the color animation track. I hooked up a branch and a boolean, setting before and after the timeline. I used a branch to gate the dynamic material, and when the timeline played through, it would execute a reset on the randome value function I created.
Here is my construction script, this is where I set my dynamic material instances for the bottom of the block, and the spikes which do a material swap later in the blueprint.
Finally, the last thing I did was rig the hitboxes. "On component, Begin overlap" casts to the player character and the kill function our instructor set up in the character blueprint.