35 lines
688 B
C#
35 lines
688 B
C#
using UnityEngine;
|
|
|
|
public class Player : MonoBehaviour, IPlayer
|
|
{
|
|
public float jumpforce = 4f;
|
|
public Rigidbody BallRb;
|
|
public bool isDead { get; private set; }
|
|
|
|
void Start()
|
|
{
|
|
if (BallRb == null)
|
|
{
|
|
BallRb = GetComponent<Rigidbody>();
|
|
}
|
|
}
|
|
|
|
void OnCollisionEnter(Collision collision)
|
|
{
|
|
if (collision.collider.CompareTag("Platform"))
|
|
{
|
|
BallRb.linearVelocity = new Vector3(0, jumpforce, 0);
|
|
}
|
|
else if (collision.collider.CompareTag("Death"))
|
|
{
|
|
Die();
|
|
}
|
|
}
|
|
|
|
void Die()
|
|
{
|
|
Debug.Log("Player is Dead");
|
|
isDead = true;
|
|
}
|
|
}
|