Daily Progress — Setting up the Spider

Esteban Ibarra
4 min readAug 10, 2021

As with other enemies, todays lecture was about preparing the spider by slicing the sprite sheet and then placing a preliminary sprite on screen and placing it inside an empty holder. Like the player, we named the original image “Sprite”, and the holder “Enemy_Spider”. We also resized the sprite to 3x the size for an especially horrific enemy.

An idle animation was created

and a walk…

Then we worked on its animation tree:

From idle to walk, the exit time stays, but 0 transition time.

From walk to idle, we’ll create a trigger called Idle, and use that as a condition. We’ll turn off exit time and 0 transition as well.

As with the Moss_Giant, We’ll create waypoints by duplicating the spider and calling it Point_A_Spider and Point_B_Spider and then delete everything leaving only the transforms.

Next, I dragged the Spider script into the Spider empty object, changed the speed to 2, and dragged the waypoints into their proper holders.

We were then told to recreate the same behaviors as the Moss Giant, but not just copy and paste, but do iteration testing which makes sense. Taking on too much at once would lead to messy code and a lot of confusion, you want to work on each feature individually, make sure it works, and then build up. It makes sense.

So let’s begin with moving the spider to Point B.

And does it work?

Sure does! Let’s put the movement in its own movement method.

Now let’s create _currentTarget variable and use that instead.

Is our spider still behaving the same?

Sure is! Let’s finally create a _step variable for the speed.

Things are a bit more readable now, at least for movement. Now let’s get a little back and forth happening. We’ll check to see if the spider reached the waypoint and if it did, the current target changes to the other waypoint, and vice-versa.

So far, so good!

Let’s get the spider stopping during the idle.

Test it…

Good! Let’s stop it at both waypoints with _anim.SetTrigger(“Idle”).

It repeats the idle animation at the beginning, we can fix that by setting the walking animation as default.

Perfect! Now to finally flip it when it moves back.

And just like that, we have a patrolling enemy!

--

--