- Home /
need help with physics.overlapsphere
if (photonView.IsMine)
{
////// ////// ////// ////// ////// ////// ////// ////// //////Killing
///////// ////// ////// ////// ////// ////// ////// ////// //////Killing
this.gameObject.layer = 1 << 1;
float bestDistance = 9999999f;
Collider bestCollider = null;
int playerLayer = 1 << LayerMask.NameToLayer("players");
Collider[] hitColliders = Physics.OverlapSphere(myPlayer.transform.position,10f, playerLayer);
foreach (var hitCollider in hitColliders)
{
float distance = Vector3.Distance(myPlayer.transform.position, hitCollider.transform.position);
if (distance < bestDistance)
{
bestDistance = distance;
bestCollider = hitCollider;
}
}
Debug.Log("killDistance");
killButton.a = 1f;
if (Input.GetKeyDown("e") && hitColliders.Length == 0)
{
return;
}
else if (Input.GetKeyDown("e") && hitColliders.Length != 0)
{
PhotonNetwork.Instantiate("AmongDie", bestCollider.transform.position, Quaternion.identity);
myPlayer.position = bestCollider.transform.position;
}
if (hitColliders.Length == 0)
{
killButton.a = 0.4f;
Debug.Log("notKillDistance");
}
//////////////////////////////////////////// /////////killlingEND
//////////////////////////////////////////// /////////killlingEND
}
how can i make it so that the origin point isnt detected in this sphere. even with this.gameObject.layer = 1 << 1; it still detects origin point.
Comment
Your answer
Follow this Question
Related Questions
Asteroid Field Physics 2 Answers
Sprite does not rotate with a CircleCollider2D 1 Answer
Physics engine with double precision 0 Answers
Unity DOTS Physics constraint linear and angular x,y,z 0 Answers
Angry Birds Slingshot 0 Answers