Cannot Implicitly Convert 'TurretAI()' To 'TurretAI'

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AttackCone : MonoBehaviour {
public TurretAI turretAI;
public bool isLeft = false;
void Awake()
{
its here -----> turretAI = gameObject.GetComponentsInParent();
}
void OnTriggerStay2D(Collider2D col)
{

if(col.CompareTag(“Player”))
{
if(isLeft)
{
turretAI.Attack(false);
}
else
{
turretAI.Attack(true);
}
}
}
}

Please use code tags .

But the answer is that your have used the GetComponentsInParent (plural) which returns an array instead of a single component which is what your turretAI field is. You should have used GetComponentInParent.

1 Like

thanks for the help and i will use code tags next time

For the information you can also edit your posts, so future readers can get information easier.