Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Player2 : MonoBehaviour {
- public float debounce = 2f;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- transform.position += new Vector3(Input.GetAxisRaw("Horizontal")*5*Time.deltaTime,0,0);
- if (Input.GetAxisRaw("Horizontal") > 0) {
- transform.eulerAngles = new Vector3(0,360,0);
- } else if (Input.GetAxisRaw("Horizontal") < 0) {
- transform.eulerAngles = new Vector3(0,180,0);
- }
- if (debounce > 1) {
- if (Input.GetAxisRaw("Vertical") > 0.5) {
- Debug.Log (Input.GetAxisRaw("Vertical"));
- Debug.Log(transform.position.z);
- Debug.Log(transform.position.z <= 8f);
- Debug.Log(12.15f <= 8f);
- transform.Translate(new Vector3(0,0,(transform.position.z <= 8f) ? 4.05f : 0));
- debounce = 0;
- } else if (Input.GetAxisRaw("Vertical") < -0.5) {
- Debug.Log (Input.GetAxisRaw("Vertical"));
- Debug.Log(transform.position.z);
- Debug.Log(transform.position.z >= -8f);
- Debug.Log(-12.15f >= -8f);
- transform.Translate(new Vector3(0,0,(transform.position.z >= -8f) ? -4.05f : 0));
- debounce = 0;
- }
- } else {
- debounce += Time.deltaTime;
- }
- if (Input.GetButton("Jump")) {
- 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))) {
- GetComponent<Rigidbody>().AddForce(Vector3.up * 150);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement