Quantcast
Channel: Latest Questions by 07Mr07
Viewing all articles
Browse latest Browse all 59

How change target with GameObject.FindWithTag

$
0
0
I have a turret and should do: -when see an enemy shoot, when he is out of range or dead(destroyed), turret must target next enemy. But my script is doing: -target first enemy and only target rest when first dead function Update() { target = GameObject.FindWithTag("Enemy").transform; if(target && range) { var rotate = Quaternion.LookRotation(Objetivo.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp); if (nextShotTime <= Time.time) { Shoot(); nextShotTime = Time.time + timeBetweenShots; } } } I need turret target next enemy when 1st out of range

Viewing all articles
Browse latest Browse all 59

Trending Articles



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