From 999055b8f8b6faf37073d651592205860d55d768 Mon Sep 17 00:00:00 2001 From: Kerby Tineus Date: Sat, 25 Jun 2016 14:31:21 -0400 Subject: [PATCH] Merge Kerby --- Assets/Scripts/JumpingPlayer.cs | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Assets/Scripts/JumpingPlayer.cs diff --git a/Assets/Scripts/JumpingPlayer.cs b/Assets/Scripts/JumpingPlayer.cs new file mode 100644 index 0000000..247ae9b --- /dev/null +++ b/Assets/Scripts/JumpingPlayer.cs @@ -0,0 +1,42 @@ +using UnityEngine; +using System.Collections; + +public class JumpingPlayer : MonoBehaviour +{ + + public float jump = 0f; + private Rigidbody rb; + private bool isGrounded; + Vector3 up; + + + void Start() + { + up = new Vector3(); + rb = GetComponent(); + } + + void OnCollisionEnter(Collision collision) + { + if (collision.gameObject.tag == "Ground") + { + isGrounded = true; + Debug.Log(isGrounded); + } + Debug.LogWarning(isGrounded); + + } + + // Update is called once per frame + void FixedUpdate() + { + if (Input.GetButtonDown("Jump") && isGrounded) + { + up = rb.velocity; + up.y = jump; + rb.velocity = up; + isGrounded = false; + Debug.Log(isGrounded); + } + } +}