

Preview text:
using System.Collections;
using System.Collections.Generic; using UnityEngine;
public class PlayerControl : MonoBehaviour {
// Start is called before the first frame update public float moveForce = 20f;
public float jumpForce = 300f;
public float maxVelocity = 4f; private bool isGrounded; public int _score = 0; private Rigidbody2D myBody; private Animator animator; Start() void { } Awake() void { myBody = GetComponent(); animator = GetComponent(); } Update() void {
// if (Static.s_score >= 10) {
// Application.LoadLevel("Scene2"); } }
// Update is called once per frame FixedUpdate() void { PlayerWalk(); } PlayerWalk() void { float forceX = 0f; float forceY = 0f;
float vel = Mathf.Abs(myBody.velocity.x);
float h = Input.GetAxisRaw("Horizontal"); if (h > 0) { if (vel < maxVelocity) { forceX = moveForce; }
Vector3 scale = transform.localScale; scale.x = 2f; transform.localScale = scale;
animator.SetInteger("state", 1); } else if (h < 0) { if (vel < maxVelocity) { forceX = -moveForce; }
Vector3 scale = transform.localScale; scale.x = -2f; transform.localScale = scale;
animator.SetInteger("state", 1); } else if (h == 0) {
animator.SetInteger("state", 0); }
if (Input.GetKey(KeyCode.UpArrow)) { if (isGrounded) { isGrounded = false; forceY = jumpForce;
animator.SetInteger("state", 2); } } if (Input.GetKey(KeyCode.F)) {
animator.SetInteger("state", 4); } if (Input.GetKey(KeyCode.G)) {
animator.SetInteger("state", 3); } if (Input.GetKey(KeyCode.H)) {
animator.SetInteger("state", 5); }
myBody.AddForce(new Vector2(forceX, forceY)); } OnCollisionEnter2D(Collision2 void D target) { if (target.gameObject.tag == ) "Ground" { isGrounded = true; } } }