Week 5 - Adding Mechanics to the Player and Fixing Bugs
- Patrick Sharpe
- Feb 26, 2021
- 3 min read
In Week 5, I started off adding two key variables which was Health and Stamina to the third person character and was displayed on screen using two progress bars on a widget. I also included the max stamina and max health for the use of pickups what will be added in week 6.
Health & Stamina Process
There was no videos recorded in this week so I will have to explain what worked and what didn't work when doing some testing. When adding the health to the player, I mistakenly forgot to add the regeneration of health when I "finished" adding the health. However, I was able to make a collision between the cube and the player to loss a value of 10 Health. Adding Stamina was more difficult as it had to link max walk speed to the stamina so that when the player sprints, stamina will be drained and the player will recover after a number of seconds pass by. However, I ran into some issues such as stamina not recovering and the player wouldn't be able to run anymore. I eventually fixed it with adding a branch after checking if the value of current stamina is less than or equal to 0. The branch would check if the player is not moving and if this was true then the player would not waste stamina.
Stamina Fixes
Death Event to Try Again Widget
This event that I created made the game un possess the player when losing all of the player's health. This included adding a fade to black transition to the widget that i created to show the player that they had died and to try again. Although the widget screen only lasts a few seconds until the game basically resets it self. In the widget I have added buttons so that when I am just working on all of the widgets. I will be able to make the buttons functional at that point.
Creating Bullet projectile in Maya
I wanted to create a better shape of a bullet projectile rather than use the traditional sphere. Considering i was working on another module using the software "Maya". I chose to create my own bullet using sphere that was cut in half and scaled up to fit the shape of a bullet. I kept the bullets low poly so that the game would run better with other mechanics that I'll be adding in the coming weeks. I imported the bullet into the project with no issues and created a material using a metal texture found on textures.com. However, after trying to add the texture and an emitter with colour in together. I ended up not using the texture as using the emitter suit the audience of the game and appears a lot better.
Shooting Mechanic
I started off creating this mechanic by adding a line trace by channel with using the starting location of the muzzle of the gun and the ending location being where the direction of the gun is pointing at. I used a branch to check whether or not the projectile bullet should fire pressing left mouse button when aiming or not aiming. I decided to make it a function as I will be adding different targets and ranges of how far the direction of the projectile can move. At this point, I will be using the same function with minor changes of the projectile type being changed depending on the gun. for this instance, I used a Pistol and an Assault Rifle for testing. Also, I added a sphere collision around the projectile mesh and each time the projectile was shot, it would disappear. When shot at a certain object, that object would be destroyed such as the cover.
After testing out the shooting, I found out that both weapon animations had to be slightly configured to keep the player from firing the projectile at himself or in the wrong direction. I will be fixing this issue next week.
Pistol Aim Offset
Creating an aim offset for the pistol wasn't difficult to do as I had already done the assault rifle offset. I only had to use the same animations used in Assault Rifle and exported a new version of the animation for the Pistol only. The process of doing this was very tedious but it needed to be done or else the player wouldn't be able to aim accurately.
After I added them to the aim offset, I then had to try and add a way so that the player switches aim offsets targeted at the gun that they have currently equipped. However, the pistol never decided to use the pistol aim offset which I will have to find some answers online to find out how to fix it.
Comments