Tag: Programming

Weapon Upgrades

Last week we began discussing having various weapons in our game, so we decided to have them as a sort of “Temporary” upgrade. Currently the player starts with just a pistol. It has a medium fire rate, basic 1 shot pattern and the projectiles move at a somewhat normal pace. On top of this, since it is the starter weapon, it has infinite ammo as well.

Marcus mentioned something that was already on my mind, which was that we should have weapons that have unique patterns that offer new gameplay aspects. After some discussion with the team, we decided to have a simple test weapon to see how the concept would handle, so I decided to do a shotgun. The weapon handles just like one would expect: It fires several bullets in a somewhat wide cone spread, slow rate of fire and unlike the pistol, it has limited ammo.

Currently, the shotgun is a derivative of the pistol, which acts like the overall prefab for all current and future guns. The weapon is setup to have a current ammo count, overridable firing function and fire rate setting. Whenever I pick up a weapon, it runs through all the player children to see if there is an already existing weapon. If there is, it will remove it, then position itself over the player and apply to become a child of the player.

  • The ammo count is set to be -1 by default. The reason I do this is to quickly indicate that the weapon is running on infinite ammo instead of having to rely on a separate value. It doesn’t cause any issues since I only check the “Take away ammo” function as long as your ammo is above 0. Alongside with this, I made the ammo counter show up below the crosshair, since most of the time, the player will be looking at where he is aiming making it easier for him to focus on how much ammo he has left.
  • The overridable firing function allows me to quickly make a new fire pattern should I require it. As mentioned, I already have a shotgun spread pattern which I simply made by running a “for loop”, each iteration giving a new aim angle for the projectile.
  • The firing rate ties in directly with the fire function, since I need it to make proper unique firing patterns, such as a slow firing sniper rifle which penetrates through enemies or a fast firing light-spread assault rifle.

2017024cc95487

Player avatar interactivity

When I first began to implement the player avatar, it became apparent that it felt very lifeless. This wasn’t due to a lack of animations, but mainly because it sensed a lack of reaction whenever the player gave input, especially from the player’s free aim movement.

At this point I only had basic player X-Axis flipping in order to indicate that you are aiming at a different direction on the horizontal level. Originally I had this tied to whichever direction you were moving in, but I soon realized how easily this conflicted with the free aim mechanic, so I switched it.

I decided to look through some old 2D games to see how developers made their characters feel more alive, besides having good animations. That’s when I remembered an old game from my childhood called Worms. The worm avatars gave me several ideas on what I could use, one of which was how they aimed weapons.

Instead of having their hands be part of their normal body, it was actually part of the weapon sprite. Even though there is nothing that’s connecting their hand to their body, it felt quite natural whenever they aimed up and down.

That alone gave a lot of life into the player avatar, but it was no enough in my opinion, so I continued to look at what else they did. I noticed that the worms’ eyes followed the player’s crosshair, giving the impression that the avatar is looking at where the player is currently aiming.

One fragment I haven’t implemented yet, but is on my to-do list, is to add eyelid movement as well. Blinking feels like a natural action to expect from your avatar, even more so, in combination with eyebrows, it can work for expressing different types of emotions. Such as when the player takes damage, or starts firing their gun.

The next and final step in this entry I think should be character animations. In my case, since I am working on Selfish, the fish itself won’t have that complicated of an animation set, but even having a simple Idle animation would help the character feel more responsive.