LookAt function C#

I have been trying to implement a feature in my game where a turret should detect an enemy, it then fires an arrow at the enemy which follows the target. I have been trying to use the LookAt function to accomplish this but it is safe to safe I have been unsuccessful. Here is the code.

public class TurretScriptTest : MonoBehaviour {
	
	public GameObject arrowPrefab;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		
	
	}
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            //Destroy(other.gameObject);
			GameObject arrowPrefab=(GameObject)Instantiate(
arrowPrefab,
	transform.position,transform.rotation);
			transform.position =other.gameObject.position;
			transform.LookAt(other.gameObject);
            
        }
    }

}

If any one has any advice please help!

You can’t access “position” straight from the gameObject. You need to get its transform first and then get the position from the transform. Also, the LookAt method takes a transform (or Vector3), not a gameObject. Try this:

void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            //Destroy(other.gameObject);
			GameObject targetSoundObject=(GameObject)Instantiate(
arrowPrefab,
	transform.position,transform.rotation);
			transform.position =other.gameObject[COLOR="red"].transform[/COLOR].position;
			transform.LookAt(other.gameObject[COLOR="red"].transform[/COLOR]);
            
        }
    }

That will get rid of your compilation errors, but I’m still not exactly sure what your code is trying to do.

Thanks for the reply, it got rid of the errors but hasn’t got the arrow firing. Basically when the enemy collides with the trigger an arrow is spawned and moves towards the enemy with the arrow head pointing at it.