Its a short script so I pasted it here. So my Exit trigger won’t work nothing happens. The enter works no problem. Nothing gets destroyed or turned off except as you can see some game object components which does not effect this script or the game object its attached to or the colliding object.
ObjectA has box collider with trigger activated
ObjectB has box collider no trigger and a rigidbody.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ReleasedObjects : MonoBehaviour
{
public OVRGrabbable grabber;
public Transform releasePosition;
public string tagname;
private Transform positionRelease;
public GameObject parentObject;
void Start()
{
positionRelease = releasePosition;
}
void OnTriggerEnter(Collider replace)
{
if (replace.gameObject.tag == tagname)
{
gameObject.GetComponent().sheath = true;
gameObject.GetComponent().isKinematic = true;
gameObject.transform.parent = parentObject.transform;
transform.position = positionRelease.transform.position;
transform.rotation = positionRelease.transform.rotation;
}
}
void OnTriggerExit(Collider hand)
{
if (hand.gameObject.tag == tagname)
{
gameObject.GetComponent().inHand = true;
}
}
}