Road TO Dev — Let’s Sway! New enemy movement.

Objective: Give our enemy a secondary movement and setup a random rate at which the new movement enemy is spawned.

Step 1: Create the variables for toggling between movement modes along with being active and the variable for the movement offset.

Step 2: Create the randomizer to determine with the new movement is happening in start.

Step 3: Setup calculate movement logic to change depending on the sway variables.

Step 4: Create the new coroutine to handle the offset.

Final Note: I use Smoothdamp here to stop the jittering of the movement. Also the speeds are entirely up to you and you could create a variable serialized to test in the inspector more easily.