Пример #1
0
 public void Init(ConveyorSystem cs)
 {
     conveyor    = cs;
     pointIndex  = -1;
     targetPoint = null;
     conveyor.SetTarget(this);
 }
Пример #2
0
 private void Update()
 {
     if (targetPoint != null)
     {
         Vector3 direction     = abs(targetPoint.position, transform.position);
         Vector3 directionToGo = targetPoint.position - transform.position;
         transform.Translate(directionToGo.normalized * speed * Time.deltaTime);
         if (direction.z < maxDistance && direction.x < maxDistance)
         {
             conveyor.SetTarget(this);
         }
         Vector3    lookDir        = targetPoint.position - model.position;
         Quaternion lookRotation   = Quaternion.LookRotation(lookDir);
         Vector3    rotationToLook = Quaternion.Lerp(model.rotation, lookRotation, Time.deltaTime * rotationSpeed).eulerAngles;
         model.rotation = Quaternion.Euler(0f, rotationToLook.y, 0f);
     }
 }