Enemie Polish

Hello everyone. I have been working on and polishing the enemies in our game. In particular the Dragonfly, Spider, and the Wasp. First up was the Dragonfly. We wanted to clean the enemies as they play an essential role in our game and because what we had was mainly placeholder enemies so we could focus on more critical issues we had.

I modified the pattern to how it moved so it would be more erratic. More specifically I made so it gets a random position moves to it then it multiplies the Y position by minus one, so it inverts it the place it occupies in the Y-axis. Then set its Y position to what it was before it starts to move zigzag, and it repeats this process till it gets outside the screen border. DragonflyMovement.gif

Then I worked on the spider. The spider just needed to start moving up and down and the projectile required to aim at the player. The moving just changed it direction randomly to move up or down. Moreover, it inverted its course when it hit the camera border in Y-axis or hit the zero in the Y-Axis. To make the projectile to aim at the player, I used Pythagoras where the spider position was the top point, and the player was the bottom point. By removing spider position in Y-axis from the player Y-position, I got the delta Y, the same was used to obtain delta X. When I got delta Y and delta X, I could use Pythagoras and get the hypotenuse from that. When I got the hypotenuse, I used arc-cos to get the degree. Unity gives you the degree in radians, so I needed to convert it to degrees using the formula degree = radians * (180 / PI) then I added the degrees to the rotation of the bullet and voila it aims at the player. A minor problem I encountered was that if the player was above the spider the bullet still pointed downwards, so I put a check in if the player was above the spider, it inverted the degrees, and everything worked like butter then.

SpiderBehavior.gif

Lastly, it was the wasps’ turn to be upgraded. It was mainly the movement that got improved, before the upgrade the wasp always turned back to its original position. However, thanks to unity magic and the function Random.insideUnitCircle it was solved quickly. There were some problems tho, and one was that the circle always had the radius of one, but Unity documentation had solved it by multiplying the function with the space we wanted, so it was easy. The second issue we had was that the circle always was centered at zero X, zero Y, and zero Z, I solved it by adding the original position to the randomized post. WaspBehaviour.gif

So just like that was all the enemies upgraded and polished.

2 reaktioner till “Enemie Polish”

  1. Hello Adam! The first couple of sentences made it instantly clear as to what the post is about, the second half of the first paragraph is not as clear however. Considering that you are a programmer I take it that the enemies in the game has been, up until this point, in a placeholder state coding wise. I do, however, recall that the dragonfly looked differently before and acted fairly similarly to the way it does right now. It would have been nice to know which of the enemies that you were polishing was in a placeholder state before and which of them were basically ‘done’.

    I like that you have included gifs, they help with the visualization of what was written about that particular enemy. I do think that it would have been prettier and it would also have made it easier to read about how the Spider shoots at the player if you had some sort of visuals accompanying the text.

    I am not quite sure what the last sentence of the Wasp paragraph means, what is the randomized post?

    Have a good one! /Daniel.

    Gilla

Lämna en kommentar