任意の攻撃ポイントに対してシールド成功かどうかをチェックする
盾のオブジェクトに攻撃発生座標を渡して、ガードが成功したかどうかを判定したいような場合、下記のようにPhysics.CheckSphereを使った。
public bool IsGuardSuccess(Vector3 attackPoint) { if (Physics.CheckSphere(attackPoint, shieldRange)){ Instantiate(guardEffect, this.transform.position, this.transform.rotation); return true; } return false; }
Physics.CheckSphereは、特定の座標に球の当たり判定を発生させてその結果を知る事ができる。
カプセル上に判定したい場合は、CheckCapsuleを使う。
http://docs.unity3d.com/Documentation/ScriptReference/Physics.html