Quantcast
Channel: Latest Questions by zeuo
Viewing all articles
Browse latest Browse all 90

script not working on second character

$
0
0
so i have a script here it works fine but then it doesnt work on the second character even thou they are copys of each other anybody know what im doing wrong var waypoint : Transform[]; static var speed : float = 5; private var currentWaypoint : int; function Update () { var Enemy = GameObject.FindWithTag ("Enemy"); if ( Vector3.Distance(Enemy.transform.position, transform.position ) < 3) { transform.LookAt(Enemy.transform); print("suck mun dee"); rigidbody.constraints = RigidbodyConstraints.FreezePositionX |RigidbodyConstraints.FreezePositionZ|RigidbodyConstraints.FreezePositionY; } if(currentWaypoint < waypoint.length) { var target : Vector3 = waypoint[currentWaypoint].position; var moveDirection : Vector3 = target - transform.position; var velocity = rigidbody.velocity; if(moveDirection.magnitude < 1) { currentWaypoint++; } else { velocity = moveDirection.normalized*speed; } rigidbody.velocity = velocity; } }

Viewing all articles
Browse latest Browse all 90

Trending Articles



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