Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ------ BoltController script ------
- #pragma strict
- private speed : float;
- private target : Transform;
- private moving = false;
- function FireAt( target : Transform, speed : float )
- {
- this.target = target;
- this.speed = speed;
- moving = true;
- Destroy(gameObject, 5);
- }
- function Update () {
- if (moving) {
- transform.LookAt(target);
- transform.Translate(transform.forward * Time.deltaTime * speed);
- if (Vector3.Distance(transform.position, target.position) < 0.1) {
- transform.position = target.position;
- moving = false;
- Destroy(gameObject, 0.2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment