Skip to content

Commit

Permalink
Merge pull request #43 from BerceniSoft/andreea/prevent-overlaping-wh…
Browse files Browse the repository at this point in the history
…en-spawning

Prevent enemies from spawning in other objects.
  • Loading branch information
brown121407 committed Dec 4, 2022
2 parents e60884b + f4c35dd commit 872e038
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ private Vector3 GetRandomPosition()
{
var randomPosition = new Vector3(Random.Range(-maxWidth, maxWidth), 0.5f, Random.Range(-maxWidth, maxWidth));
var distance = Vector3.Distance(transform.position, randomPosition);

if (distance < maxDistance)
{
continue;
if (Physics.CheckSphere(randomPosition, 0.7f, (int) Layers.Floor))
{
continue;
}
}

return randomPosition;
Expand Down

0 comments on commit 872e038

Please sign in to comment.