Assessment Lead-Up Tests

Soon we will be doing an assessment to test our ability to program so we have been making test games to test the scripts that we will be using in the assessment. I haven’t made many assets yet however I have made some scripts using placeholder assets to test them.

I started with making the movement script…

Variables.PNG

Here is the variables for the movement script. This asks to identify the rigidbody so it can be moved later in the script. It also creates a value for power which determines how fast the player moves. This can also be edited outside of the code as Unity allows me to change this value.

Function.PNG

Here is the function I used to make the player move. The first line of this function creates the direction variable which is determined by the players input. This takes both the wasd and arrow keys movement so the player can use either of those. This takes the 2D directions using Vector2 as it has the horizontal and vertical directions within it.

The second line takes that direction and multiplies it by the power that is determined in the variables to create a force variable which is then used to give the rigidbody a velocity in the third line which allows it to move. I call this function within an update function so this is being checked every frame to allow constant movement.

Player movement.gif.gif

I then made it so that there was a collectible for the player to obtain as well as an end goal for the player to go to after they get the collectible.

Using.PNG

I have added scene management to this script so that it can change which scene is currently loaded later on in the script.

Variables.PNG

These are the variables for that. This creates a variable that will be changed later on in the code that determines whether the collectible has been picked up or not yet. It also has a variable for the next level that has to be typed in within Unity so it knows which scene to load later in the script.

Function.PNG

This function is triggered whenever the player enters the trigger that is within the hitbox of an object. This immediately checks what the tag of the object of it is and on the second line you can see that it is looking for tag of “collectible” which is determined in unity. The third line has been commented as it was only used to check that everything was working by placing a message in the log. The last two lines of this destroy the collectible to give the illusion that it has been collected and it also makes the variable for collected that was seen before and makes it true.

else.PNG

This bit of code activates if the trigger doesn’t have the tag outlines previously. This checks if the collectible has been picked up by the player by checking the variable from before.

After this it loads the scene from the other variable that tells it what the next scene should be. There is also a debug bit still in the code to tell me that it is still working.

Collectables.gif

I then placed an enemy in the world and made it so that the enemy had the ability to kill the player if they were to collide

.using.PNG

variable.PNG

This is a fairly simple script as it only has one variable that does the same thing as the previous script had where it determines which scene to load later in the script and it also has the same scene management that I used in the previous script.

function.PNG

This script is similar to the last one as it starts when the player enters a trigger and it tries to find the tag that the trigger has attached to it which in this case is “enemy”. This also has a commented debug in which I used to make sure that this script works.

The last line of the function then loads the scene that I determined in Unity which makes a functioning death script come together.

Death.gif

Next I made it possible for the enemy to move.

variables.PNG

There is a few variables for this script. The first line of this makes an array that can hold the different points that the enemy has to move to. The second variable sets a move speed for the enemy to move between the waypoints.

Movetowardstarget.PNG

This script tells the object to move towards the waypoint by using a vector3 to move towards the objective. This is made a simple movement over time by taking the movement speed and multiplying it by time.deltatime to make it happen over time instead of being once a frame.

check arival.PNG

This function checks that the object makes it to its objective by checking that the current position of it matches the position that the way point has determined at.

start and update.PNG

within the start and update functions I have made it so that the position of the object starts at the first waypoint and I have called the previous functions each frame.

Gizmos.PNG

This last bit of code draws out where the waypoints would be in the unity editer however these do not show up when the game is playing. This is useful for letting the game work as it lets me freely place my waypoints.Enemy movement.gif

I am quite happy with where this is going so far however it still needs some assets made for it so that a theme can be made for this game. There are some more mechanics that I will add in later as well however that will need to be added as the game develops more.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s