Beispiel #1
0
 void Update()
 {
     if (thrower == null)
     {
         thrower = FindPlayer();
     }
     if (source.GetThrower() != null && !hotness.GetIsHot())
     {
         source.SetThrower(null);
     }
     if (returning)
     {
         rigid.velocity = (thrower.transform.position - this.transform.position).normalized * (speedBoost);
         if (Mathf.Abs(Vector3.Distance(thrower.transform.position, this.transform.position)) < 1f)
         {
             Destroy(this.gameObject);
         }
     }
     else
     {
         if (thrower == null)
         {
             thrower = FindPlayer();
         }
         if (thrower != null && Mathf.Abs(Vector2.Distance(thrower.transform.position, this.transform.position)) > maxDistance)
         {
             returning = true;
         }
     }
 }
Beispiel #2
0
 public void OnTriggerEnter2D(Collider2D coll)
 {
     if (hotness.GetIsHot() && smackable && coll.tag == "Smack")
     {
         rb.velocity = (transform.position - coll.transform.position).normalized * knockbackSpeed;
         source.SetThrower(coll.gameObject.transform.parent.transform.parent.GetComponent <PlayerData>());
     }
 }