I created this simple enemy controller. I get the position of the player, then if the distance is less than five it follows the player by setting its position to move towards the player. Then if it is greater the enemy simply stands still.
If I were to expand I would make it so the enemies wander around until they find the player if not in range.
For the movement, I created a script that would handle the player inputs and convert them into movement. For the movement, I wanted to focus on adding in the basic stuff, so I added some basic floats for the movement variables. For the movement I get the horizontal and vertical inputs in the update function, I will use these to get the players' inputs. Then in a function to handle input, I use the horizontal input to add velocity to the player's rigidbody. To add Air control I create some variables for the air control. Then if the player is grounded I apply the air control to the velocity.
For the on-ground bool, I send a ray cast down to check for a ground floor. If this is true that means the ray cast has detected a ground if not abilities like jumping and air control will be disabled. In the handle movement, I make sure the player's sprite is flipped based on the direction the player is going. This is not useful now but it will come in handy when the player is animated. To get jumping working I add the is grounded to a handle jump function. If the space key is held down and the player is grounded I add force to the player's rigidbody using the jump force. I set some bools to true or false based on if the player is jumping.
For the menu, I started with a script that handles basic functions. These will be linked to buttons so the menu can function. First, there is the play function which loads the next level after the one currently running. Then there is the Quit function which quits the application. Then there is the load level IEnumerator is used for the transitions which are animated circles.
The next script is in control of switching characters in the character select. First, there is a set array of game objects for the player options. Then there is the privately selected character. the choose character function picks a character by taking in an int. The int is set by the button of the character with one being the ranger and so on. Then it calls the spawn function. The spawn function loads the next scene and then instantiates the chosen character.
Next is the first part of the character walking across the screen scripts. in the main menu, a character walks across the screen being random each time. To get that to work I needed an edge detector this first gets the second half of this system and finds it in the scene. Then it sets the collided object back to its original position. This is always going to be the most recent character to walk. lastly, it sets the reset bool to true.
The move-across script handles moving the characters across the screen. First, the start function sets all the needed variables for the animators and starts the other functions. The animator chooses the players to animate if they are on the menu, so they appear to walk. This is set so it does not affect in-game animation and only the menu animation. Then in the update function, if the reset boos are true, it picks a random character and sets it to false. Then, if the chosen sprite is available, it moves it right, so the character is always moving right.
The pick random due function selects a random sprite based on a random int and then sets the sprite to it. This script only runs if the whole is still true to stop repeat characters from showing. The set of player sprites gets the transforms from the children of this object using the get component in children. Then it sets them to an array.
I created a bunch of animations from the buttons to the text. Most of this works automatically, so I cannot show much, but you can see all this in the videos below. But I can show you the movement animator, which has some custom changes. First, it checks if it's in the menu, and then it automatically runs. This is to set the player running in the menu as stated before. Then it also has a transition if the speed is greater than 0.1, this checks if the player is moving and then plays the running animation. Then in the other direction, it checks if it is less, then sets the player back to idle.
Here is a video of the main menu
Here is a video of the character selector
Here are the videos I used as a guide