Esempio n. 1
0
 void Update()
 {
     //early exit
     if (hasHit)
     {
         return;
     }
     if (Target == null)
     {
         Emitter.Emit(new OnCastEndEventData(Caster.gameObject));
         return;
     }
     //update this position
     transform.position = Vector3.Lerp(
         Caster.position,
         Target.transform.position,
         cLifetime / Lifetime
         );
     //update the fang a position
     FangA.localPosition = BezUtils.Bez3(
         Vector3.zero,
         new Vector3(2.5f, 2.5f, 0f),
         Vector3.zero,
         cLifetime / Lifetime
         );
     //update the fang b position
     FangB.localPosition = BezUtils.Bez3(
         Vector3.zero,
         new Vector3(-2.5f, 2.5f, 0f),
         Vector3.zero,
         cLifetime / Lifetime
         );
     //update clock
     cLifetime += Time.deltaTime;
     if (cLifetime > Lifetime)
     {
         Emitter.Emit(new OnCastEndEventData(Caster.gameObject));
     }
 }
 void Update()
 {
     //update the position
     if (EndTargetBody != null)
     {
         LastSeenPos = EndTargetBody.transform.position;
     }
     transform.position = BezUtils.Bez3(
         StartPos,
         ArcPeakPos,
         LastSeenPos,
         cLifetime / Lifetime
         );
     //end attack if taking too long
     if (cLifetime > Lifetime)
     {
         Emitter.Emit(
             new OnCastEndEventData(CreatorCollider.gameObject)
             );
     }
     //update the time delta
     cLifetime += Time.deltaTime;
 }