Introducing a score limit and bugfixes
This commit is contained in:
@@ -5,6 +5,7 @@ using UnityEngine;
|
||||
public class ForceZone : MonoBehaviour
|
||||
{
|
||||
public float force = 0;
|
||||
public GameObject player;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -19,8 +20,13 @@ public class ForceZone : MonoBehaviour
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
Vector3 direction = other.transform.position - this.transform.position;
|
||||
Vector3 direction = other.transform.position - this.player.transform.position;
|
||||
Debug.DrawRay(this.transform.position, direction);
|
||||
other.transform.GetComponent<Rigidbody>().AddForce(direction.normalized * this.force * Time.deltaTime, ForceMode.Impulse);
|
||||
|
||||
Rigidbody otherRigidbody = other.transform.GetComponent<Rigidbody>();
|
||||
if (otherRigidbody)
|
||||
{
|
||||
other.transform.GetComponent<Rigidbody>().AddForce(direction.normalized * this.force * Time.deltaTime, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user