Introducing a score limit and bugfixes

This commit is contained in:
2019-09-26 00:48:36 +02:00
parent 3499961a98
commit 4bb1730091
3 changed files with 525 additions and 24 deletions

View File

@@ -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);
}
}
}