The Path of the Game Dev — Day 13

Gabrielle Igarta
2 min readDec 9, 2020

--

Saving progress…

— —

Enemies abound! Not only did I get deeper into making the new enemies for Phase 2, but I also worked on two other features: a UI element for the wave spawner and a fast pickup for the collectibles.

Let’s dig in -

The fast pickup required us to create logic so when the player presses the ‘C’ key the collectibles on the field would move towards the player. At first I just had the ‘C’ key increase the speed at which the collectibles moved downwards but that seemed too simple to me. I changed it to the code below:

if (Input.GetKey(KeyCode.C))
{
target = GameObject.FindGameObjectWithTag("Player").transform;
_speed = 4.5f;
transform.position = Vector3.MoveTowards(transform.position, target.position, _speed * Time.deltaTime);
}

Here, we are moving the collectible’s transform towards the target or player’s transform at a constant speed over time. This MoveTowards is useful for the collectible pickup because you want it to quickly move it towards one point — the player. I know there are other ways to get similar effects using other functions (like Lerp) but since I needed a constant speed I decided to use MoveTowards instead.

It really helped conceptually to be working on homing missiles and aggressive enemies at the same time since they both track another game object as a “target”.

Lastly, I started working on different movements for the new enemy types. To give myself a challenge I tried to make a zigzag pattern for the beam enemies to maximize their offensive potential. But getting an object to move back and first as it also continuously moves downwards is a lot more difficult than anticipated. Maybe I can share it all in tomorrow’s blog post.

Biggest takeaways from the day: The math of movement is very tricky.

— —

Progress saved!

--

--

No responses yet