mirror of
https://github.com/ConjureETS/MeltedBananasOJam2016.git
synced 2026-03-24 02:21:06 +00:00
Merge Kerby
This commit is contained in:
parent
3cecda08e7
commit
999055b8f8
42
Assets/Scripts/JumpingPlayer.cs
Normal file
42
Assets/Scripts/JumpingPlayer.cs
Normal file
@ -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<Rigidbody>();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user