How to check what touched your collider

Hello.
In my Project I have a collider and a script with an OnTriggerEnter function. So know I want to know what touches the trigger, and lock onto it (the Player Object needs to turn towards it ) .Sadly I don’t know how to do that. Pls Help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Attack : MonoBehaviour
{
    


  


  private void OnTriggerEnter(Collider collision)
    {
        Debug.Log("Collison");
        
    }  
}

Right off the bat, OnTriggerEnter has requirements:

Note: Both GameObjects must contain a
Collider component. One must have
Collider.isTrigger enabled, and
contain a Rigidbody. If both
GameObjects have Collider.isTrigger
enabled, no collision happens. The
same applies when both GameObjects do
not have a Rigidbody component.

If you are looking for a physical collision (and not just collision overlap detection), then you will want to use OnCollisionEnter.

If that is set up, then the Collider collision will have all the information you need from what collided.

You can use collision.transform.name to get the object’s name, or collision.transform.position to get its location. You can also use collision.GetComponent() to get any component from that colliding object, such at their stats and such.

In the following, the debug line gives you the name of the colliding object and the following line will cause you to look at the collider. You may want to interpolate, rather than look immediately, but that’s another question…

using UnityEngine;

public class EnemyLook : MonoBehaviour
{
    private void OnCollisionEnter(Collision collision)
    {
        Debug.Log(collision.gameObject.name);
        transform.LookAt(collision.transform.position);
    }
}