yup still cant find player even Spherecasts wont find player and Find Gamobject with tag wont find player
Love Unity, nothing ever works tried everything.
HAS TAKEN MONTHS CANT GIT IT TO FIND PLAYER SHOULD HAVE BEEN A 5 SECOND SCRIPT TO MAKE.
(started to uninstall and re-install unity in case the install is broken)
FindTag wont find player
Spherecast wont find player
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine;
public class HunterAI : MonoBehaviour
{
public GameObject TargetT;
float Distance;
private Vector3 TargetDirectionDD;
public float Speed = 30;
public float TurnRate = 120;
private Vector3 fwd;
// Start is called before the first frame update
void Start()
{
}
void Update()
{
Turn();
if (TargetT != null)
{
Distance = Vector3.Distance(TargetT.transform.position, transform.position);
if (Distance < 7)
{
TargetT = null;
}
}
if (TargetT == null)
{
Debug.Log("No Player ");
Collider[] hitColliders = Physics.OverlapSphere(transform.position, Mathf.Infinity);
foreach (var hitCollider in hitColliders)
{
if(hitCollider.gameObject.tag == "Player")
{
TargetT = hitCollider.gameObject;
Debug.Log("Found You");
}
}
}
transform.Translate(Vector3.forward * Speed * Time.deltaTime);
}
void Turn()
{
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(TargetDirectionDD), Time.deltaTime * TurnRate);
TargetDirectionDD = TargetT.transform.position - transform.position;
}
}