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

Rob Smith
Jun 7, 2021

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.

--

--

Rob Smith

Hi there! I am currently on the path to learn how to become a unity developer and will be documenting my journey as best as I can here. Thanks for looking!