Advertisement
Wiiplay123

Broken Player Script

May 27th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Player2 : MonoBehaviour {
  5.     public float debounce = 2f;
  6.     // Use this for initialization
  7.     void Start () {
  8.    
  9.     }
  10.    
  11.     // Update is called once per frame
  12.     void Update () {
  13.         transform.position += new Vector3(Input.GetAxisRaw("Horizontal")*5*Time.deltaTime,0,0);
  14.         if (Input.GetAxisRaw("Horizontal") > 0) {
  15.             transform.eulerAngles = new Vector3(0,360,0);
  16.         } else if (Input.GetAxisRaw("Horizontal") < 0) {
  17.             transform.eulerAngles = new Vector3(0,180,0);
  18.         }
  19.         if (debounce > 1) {
  20.             if (Input.GetAxisRaw("Vertical") > 0.5) {
  21.                 Debug.Log (Input.GetAxisRaw("Vertical"));
  22.                 Debug.Log(transform.position.z);
  23.                 Debug.Log(transform.position.z <= 8f);
  24.                 Debug.Log(12.15f <= 8f);
  25.                 transform.Translate(new Vector3(0,0,(transform.position.z <= 8f) ? 4.05f : 0));
  26.                 debounce = 0;
  27.             } else if (Input.GetAxisRaw("Vertical") < -0.5) {
  28.                 Debug.Log (Input.GetAxisRaw("Vertical"));
  29.                 Debug.Log(transform.position.z);
  30.                 Debug.Log(transform.position.z >= -8f);
  31.                 Debug.Log(-12.15f >= -8f);
  32.                 transform.Translate(new Vector3(0,0,(transform.position.z >= -8f) ? -4.05f : 0));
  33.                 debounce = 0;
  34.             }
  35.         } else {
  36.             debounce += Time.deltaTime;
  37.         }
  38.         if (Input.GetButton("Jump")) {
  39.             if (Physics.CheckCapsule(GetComponent<Collider>().bounds.center,new Vector3(GetComponent<Collider>().bounds.center.x,GetComponent<Collider>().bounds.min.y - 0.1f,GetComponent<Collider>().bounds.center.z),0.02003445f,~(1 << 8))) {
  40.                 GetComponent<Rigidbody>().AddForce(Vector3.up * 150);
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement