예제 #1
0
 // Update is called once per frame
 void Update()
 {
     // Rotate
     if (target)
     {
         float dist = Vector3.Distance(target.position, transform.position);
         if (dist > 30f)
         {
             thruster.SetTargetDirection(target.position - transform.position);
             thruster.SetThrustSpeed(thruster.thrustSpeedBase);
             thruster.SetThrustV(1f);// Go
             thruster.BrakeOff();
         }
         else
         {
             thruster.SetThrustV(1f);
             thruster.SetThrustSpeed(thruster.thrustSpeedBase * 0.5f);// SLOW
             thruster.BrakeOff();
             levelController.ProcessArrival(gameObject, target.gameObject);
         }
     }
     else
     {
         EventManager.TriggerEvent("haulerLost");
     }
 }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     gameObject.layer = 8;    // Ignore layer
     thruster         = GetComponent <Thruster>();
     thruster.SetThrustV(1f); // Go forward
     levelController = GameObject.Find("LevelControl").GetComponent <LevelController>();
 }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        gameObject.layer = 9;
        AssignTarget("Cargo");

        thruster = GetComponent <Thruster>();
        thruster.SetThrustBase(8f);
        thruster.SetThrustV(1f);// Go forward

        weapon        = GetComponent <Weapon>();
        weapon.origin = 1;
        // Bit shift the index of the layer (8) to get a bit mask. This would be 0000000100000000, with 1 starting all the way on the right and moving 8 steps to the left.
        // This number is the same as 256. 1<<9 would be 512. 1<<10 would be 1024.
        // For multiple layers  (1<<8) | (1<<10);
        weapon.layerMask = 1 << 8;// Ignore all but 8
    }