Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

Arrow follows nearest target please help

$
0
0
Hi, How to make the arrow follow object with "Enemy" tag Here is the script : #pragma strict var Speed : float = 20; var relativeDirection = Vector3.forward; var duration : float = 1.0; var shooterTag : String = "Player"; var hitEffect : GameObject; function Start () { hitEffect = GetComponent(BulletStatus).hitEffect; GetComponent(Rigidbody).isKinematic = true; Destroy(); } function Update () { var absoluteDirection : Vector3 = transform.rotation * relativeDirection; transform.position += absoluteDirection *Speed* Time.deltaTime; } function Destroy(){ Destroy (gameObject, duration); } function OnTriggerEnter (other : Collider) { if (other.gameObject.tag == "Wall") { if(hitEffect){ Instantiate(hitEffect, transform.position , transform.rotation); } Destroy (gameObject); } }

Viewing all articles
Browse latest Browse all 536

Trending Articles



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