user5880181
user5880181

Reputation:

Unity select random point inside radius

I need to select a random point inside a radius to send an enemy in a Unity game while they wait for their turn to attack. How do I create a radius around my gameobject and randomly select points inside it?

Upvotes: 0

Views: 2631

Answers (1)

acoolaum
acoolaum

Reputation: 2130

        Vector3 centerOfRadius = new Vector3(5, 3, 0);
        float radius = 10f;
        Vector3 target = centerOfRadius + (Vector3)(radius * UnityEngine.Random.insideUnitCircle);

Upvotes: 2

Related Questions