Advertisement
Guest User

Drone Script

a guest
Aug 19th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. public class DroneController : MonoBehaviour {
  2.     bool moving;
  3.     public float speed;
  4.     // Use this for initialization
  5.     //GameObject obj;
  6.     GameObject ast;
  7.     void Start () {
  8.         moving = false;
  9.         speed = 50f;
  10.     }
  11.    
  12.     // Update is called once per frame
  13.     void Update () {
  14.    
  15.         if (moving) {
  16.             Debug.Log ("Moving;");
  17.             Debug.Log (ast.transform.position);
  18.             float step = speed * Time.deltaTime;
  19.             transform.position = Vector2.MoveTowards (transform.position, ast.transform.position, step);
  20.         }
  21.     }
  22.  
  23.     void harvest(GameObject obj) {
  24.         Debug.Log ("Message Recieved");
  25.         ast = obj as GameObject;
  26.         moving = true;
  27.         Debug.Log (ast.transform.position);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement