edx/assignment8final/Assets/ProtoPack/Scripts/PlayerJumpTest.cs
2022-11-10 21:56:29 -03:00

52 lines
630 B
C#

using UnityEngine;
using System.Collections;
public class PlayerJumpTest : MonoBehaviour
{
Animator anim;
Rigidbody rb;
bool jump = false;
void Start ()
{
anim = GetComponent<Animator> ();
rb = GetComponent<Rigidbody> ();
}
void Update ()
{
}
void OnMouseDown ()
{
if (!jump) {
jump = true;
anim.SetBool ("jump", true);
anim.SetBool ("land", false);
rb.AddForce (Vector3.up * 200);
}
}
void OnCollisionEnter ()
{
if (jump) {
Invoke ("JumpReset", 0.25f);
anim.SetBool ("jump", false);
anim.SetBool ("land", true);
}
}
void JumpReset ()
{
jump = false;
}
}