After working some more on the game that I have been making as preparation for the upcoming exam, I have made some artwork and some more code to go with the game. Although it looks pretty basic, it is working out to be quite good so far.
To start of I made the world that the player would be working their way through with 12 pixel walls all around purely to please my OCD and 2 specified rooms where the player will have to traverse around enemies to get through the puzzle. The first room at the top has 4 entry ways however there will be an enemy patrolling around the outside of it as well as one inside that the player will have to avoid to win the game.
I then worked towards making an objective. This consists of a collectible and an exit for the level. The star is quite obviously the collectible and despite it being quite a simple design I quite like how it turned out and the exit was meant to be a basic hatch idea however you can’t really tell so it just looks like a blend of colours so that could be improved on.
The last design I made for this was the player and the enemies which follow the same design of being a simple looking person wearing a hate where the enemies are wearing red hats to show that they are dangerous.
I also made some code today as well…
This is the variables that I used for this script that is meant to make it so that the bullet is launched from the enemy every few seconds. The first variable finds the prefab for the projectile so it can spawned later on in the code. The other two are variables that will be used for maths later on in the code.
This first function is quite simple as when it is called it creates an instance of the prefab previously specified in the same position and rotation as the object that it is being launched from.
This function makes it so that every frame it is checking if the shot timer is greater than the rate of fire which will call the shoot function and reset the shot timer if it does.
Otherwise it will constantly be adding a factor based on time onto the shot factor which makes this a constant shooting timer that will fire about every 2 seconds.
This works together with another script that allows the projectile to move…
The first of these variables looks for the rigidbody of the prefab so that it can move it across the screen. I also created some variables that can be used in calculations later on in the code.
When the object is created this code makes the rigidbody have a movement speed using the firepower as a multiplier to make it move at a constant speed.
This update function makes it so that there can’t be too many projectiles. It does this by taking the lifespan and taking a time value away from it every frame. It also checks if the lifespan is less than or equal to zero and if this is true then it removes it which makes it so that there can’t be too many of them.
This is a simple script as it only has one variable which makes a target for the camera to follow.
The update function only makes the position of the camera equal to the player however it is still a distance away so you can see whats happening still.
Overall I am quite happy with what I have done so far and to improve further I will need to make it so that the enemies stop when they see the player and start shooting rather than them always moving and shooting. This will involve using raycasting to detect the player as well as changing the monobehaviour to be active or inactive to activate and de-activate scripts.