added player and danger platfroms
This commit is contained in:
6
Assets/Scripts/PlayerScript/IPlayer.cs
Normal file
6
Assets/Scripts/PlayerScript/IPlayer.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public interface IPlayer
|
||||
{
|
||||
bool isDead { get; }
|
||||
}
|
||||
2
Assets/Scripts/PlayerScript/IPlayer.cs.meta
Normal file
2
Assets/Scripts/PlayerScript/IPlayer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eea067ca01685f4790d3cd0214321ea
|
||||
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;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/PlayerScript/Player.cs.meta
Normal file
2
Assets/Scripts/PlayerScript/Player.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a23214d81cfb862488bd856cfdffb896
|
||||
Reference in New Issue
Block a user