This section will cover the code that is present in this chapter:
Here's the code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public static PlayerController instance;
public float jumpForce = 6f;
public float runningSpeed = 1.5f;
public Animator animator;
private Vector3 startingPosition;
private Rigidbody2D rigidBody;
public AudioClip killSound;
void Awake() {
instance = this;
rigidBody = GetComponent<Rigidbody2D>();
startingPosition = this.transform.position;
}
public void StartGame() {
animator.SetBool("isAlive", true);
this.transform.position = startingPosition;
}
void Update () {
if (GameManager.instance.currentGameState == GameState.inGame)
{
if (Input.GetMouseButtonDown(0)) {
Jump();
}
animator.SetBool("isGrounded",...