Attempting to create a gravity zone that launches the player when in contact.
Here is what I have:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GavityZone : MonoBehaviour
{
public float gravityModifier = 10f;
private void OnTriggerStay(Collider other)
{
var hitObj = other.gameObject;
Debug.Log("contact");
var modifiedRB = hitObj.GetComponent<Rigidbody>();
Debug.Log("Rigidbody retrieved ");
if (modifiedRB != null)
{
Debug.Log("force applied");
Vector3 forceDirection = transform.up;
modifiedRB.AddForce(forceDirection * gravityModifier, ForceMode.Impulse);
}
}
}