hello everyone, in unity I am trying to get the object with the tag Player to be detected by a box collider in istrigger, but the box collider component is on another object
here is the script that tries to do that.
using UnityEngine;
public class ObjectTrigger : MonoBehaviour
{
public Collider otherCollider;
private void OnTriggerEnter(Collider other)
{
if (other == otherCollider && other.CompareTag("Player"))
{
Debug.Log("Hello");
}
}
}
I suggest starting with any tutorial that does that.
See the docs for your OnTriggerEnter() callback for all the things it gives you as well as the requirements necessary for it to operate.
Work slowly take your time, there are many specific individual steps and requirements that MUST be met.
Imphenzia: How Did I Learn To Make Games:
https://www.youtube.com/watch?v=b3DOnigmLBY
ALSO:
Referencing GameObjects, Scripts, variables, fields, methods (anything non-static) in other script instances or GameObjects:
https://discussions.unity.com/t/833085/2
https://discussions.unity.com/t/839310