コード例 #1
0
ファイル: SpellUtilities.cs プロジェクト: IvanNSBS/Geeko-Game
 public static void PullTargetToSrc(
     GameObject target,
     GameObject src,
     float pull_str,
     List <GameObject> objs_to_ignore,
     List <string> tags_to_ignore,
     bool negate_ignore = false)
 {
     if (GameplayStatics.ObjHasTag(target, tags_to_ignore, negate_ignore))
     {
         return;
     }
     if (target.GetComponent <Rigidbody2D>() && !GameplayStatics.IsObjInList(target.gameObject, objs_to_ignore))
     {
         Vector3 pos   = src.transform.position;
         Vector3 enemy = target.transform.position;
         Vector3 dir   = pos - enemy;
         dir.Normalize();
         Vector3 newpos = (dir * 0.001f * pull_str);
         newpos = new Vector3(newpos.x, newpos.y, 0);
         target.transform.position += newpos;
         //target.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
         //target.GetComponent<Rigidbody2D>().angularVelocity = 0.0f;
         //target.GetComponent<Rigidbody2D>().AddForce(dir * m_PullStrength);
     }
 }