Cannot convert from UnityEngine.GameObject to RPG.Combat.CombatTarget

Its saying I have an error on line 24
fighter.Attack(player);

using System.Collections;
using System.Collections.Generic;
using RPG.Combat;
using UnityEngine;

namespace RPG.Control
{
    public class AIController : MonoBehaviour
    {
        [SerializeField] float chaseDistance = 5f;

        Fighter fighter;
        GameObject player;

        private void Start(){
            fighter = GetComponent<Fighter>();
            player = GameObject.FindWithTag("Player");
        }

        private void Update()
        {
            if (InAttackRangeOfPlayer() && fighter.CanAttack(player))
            {
                fighter.Attack(player);
            }
        }

        private bool InAttackRangeOfPlayer()
        {
            float distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
            return distanceToPlayer < chaseDistance;
        }
    }

}

At this point in the course, we need to make a change to Fighter.cs

Fighter.Attack will need it’s signature changed from

public void Attack(CombatTarget combatTarget)

to

public void Attack(GameObject combatTarget)

You’ll also need to make a change in PlayerController in InteractWithCombat when calling Fighter.Attack to call the combatTarget.gameObject

Privacy & Terms