
MY FIRST GAME
My very fist game.

CHARACTER: RHYS
This is my very first game character drawn with a mouse in a few seconds
Rhys is inspired by my younger brother who shares the same hair colour, He is my main character in a platformer game that I will call HELP HIM.

ALTERNATIVE SPRITE FACE
The game flips between the original sprite and this sprite to be used as an idle animation.

RUNNING ANIMATION
This is a GIF of my character Rhys running.


GAMEPLAY
This is a screenshot of my game, It's a very simple game as it is my first game. I want to expand my knowledge in game design and venture into the 3D gaming space.

CODE
This screenshot shows all the code that is in my game. Find a copy of my code in the box below.
CODE
Code for HELP HIM.
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float speed;
private Rigidbody2D body;
private Animator anim;
private bool grounded;
private void Awake()
{
// References rigidbody and animator from object
body = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
private void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);
// Flips player when moving left
if (horizontalInput > 0.01f)
transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
else if (horizontalInput < -0.01f)
transform.localScale = new Vector3(-0.3f, 0.3f, 0.3f);
if (Input.GetKey(KeyCode.Space) && grounded)
Jump();
//set animation parameters
anim.SetBool("Run", horizontalInput != 0);
anim.SetBool ("grounded", grounded);
}
private void Jump()
{
body.velocity = new Vector2(body.velocity.x, speed);
grounded = false;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Ground")
grounded = true;
}
}

GAMEPLAY
UPDATE 1: 29/01/2022
Grow And Shrink!

GROWTH!
Holding 'Q' will make the player grow in size, currently this is used to jump gaps that cannot be jumped by the player.

SHRINK!
Holding 'E' will make the player shrink in size, currently this is used to fit into places and gaps that the player cannot.
GAMEPLAY OF UPDATE 1:
This gameplay shows the new features in action!
UPDATED CODE
The bold code is the new code!
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float speed;
private Rigidbody2D body;
private Animator anim;
private bool grounded;
private void Awake()
{
// References rigidbody and animator from object
body = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
private void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);
// Flips player when moving left
if (horizontalInput > 0.01f)
transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
else if (horizontalInput < -0.01f)
transform.localScale = new Vector3(-0.3f, 0.3f, 0.3f);
if (Input.GetKey(KeyCode.Space) && grounded)
Jump();
// I am trying to see if I can work out code by myself whilst reffering to previous code, I will use the Jumping code to try and create a grown mechanic
// This is the Growth Mechanism
{
if (Input.GetKey(KeyCode.Q))
transform.localScale = new Vector3(1f, 1f, 1f);
if (Input.GetKey(KeyCode.Q))
if (horizontalInput > 0.01f)
transform.localScale = new Vector3(1f, 1f, 1f);
else if (horizontalInput < -0.01f)
transform.localScale = new Vector3(-1f, 1f, 1f);
}
// This is the Shrink Mechanism
{
if (Input.GetKey(KeyCode.E))
transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
if (Input.GetKey(KeyCode.E))
if (horizontalInput > 0.01f)
transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
else if (horizontalInput < -0.01f)
transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f);
}
//set animation parameters
anim.SetBool("Run", horizontalInput != 0);
anim.SetBool ("grounded", grounded);
}
private void Jump()
{
body.velocity = new Vector2(body.velocity.x, speed);
grounded = false;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Ground")
grounded = true;
}
}