Make Comment Default Blogger For AMP
Rotate icon by Icons8

When I’m developing my game, I want to switch weapon by array object actor ( weapon )

so, for example I have an array like this

[0, 1, 2, 3, 4]

I want to able rotate array value by index to something like this

// Rotate to right
[4, 0, 1, 2, 3]
[3, 4, 0, 1, 2]
// Rotate to left
[1, 2, 3, 4, 0]
[2, 3, 4, 0, 1]

This is my first approach function.

Unreal Engine 4 - Rotate Array Element Function

Right-click > Open image in new tab for zooming image

For debugging purpose I make variable string (ArrTest).

Unreal Engine 4 - Rotate Array Element Function

then make local variable for last / first array, and after that we delete last / first array, and final step is append array.

because append is self assign, we need assign temp array to original array when we rotate to right.

by using function we need set temp array type, that is the problem.

I want the type of array is dynamic / wildcard, it can be done in macro.

so let’s rewrite / whatever is in macro.

and this is my result, and minify logic

Unreal Engine 4 - Rotate Array Element Function

Right-click > Open image in new tab for zooming image

using macro make’s more dynamic, no more set array type

Important Logic

honestly we don’t need store boolean variable (Is Move Right)

we need clear local array wildcard because local variable on macro is storing variable from the last action, so we need to clear all array first

so now you can rotate any array type