Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Find Clone with tag

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; [RequireComponent(typeof(UnityEngine.AI.NavMeshAgent))] public class EnemyScript : MonoBehaviour { private Animator EnemyAnim; private NavMeshAgent navMesh; private GameObject player; public float enemySpeed; void Start() { EnemyAnim = GetComponent(); navMesh = GetComponent(); player = GameObject.FindGameObjectWithTag("Player"); navMesh.speed = enemySpeed; } void Update() { navMesh.destination = player.transform.position; EnemyAnim.SetBool("Walking", true); if(Vector3.Distance(transform.position, player.transform.position) < 1.5f){ navMesh.speed = 0; EnemyAnim.SetBool("Attack", true); StartCoroutine("Att"); } } IEnumerator Att() { yield return new WaitForSeconds(2.8f); EnemyAnim.SetBool("Attack", false); navMesh.speed = enemySpeed; } } would it be possible to locate a gameObject(clone) from a tag? I'm desperate for this answer as I'm trying to script my enemy's AI, and I need it to locate my player tag which is a clone of a prefab template created from a spawn script. would it be possible to locate a gameObject(clone) from a tag? I'm desperate for this answer as I'm trying to script my enemy's AI, and I need it to locate my player tag which is a clone of a prefab template created from a spawn script.

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>