added player and danger platfroms
This commit is contained in:
34
Assets/Scripts/PlayerScript/Player.cs
Normal file
34
Assets/Scripts/PlayerScript/Player.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user