I’m remaking Pop The Lock mobile game, but I’m having trouble randomly spawning the dot prefabs inside of the Circle object. transform.RotateAround works and makes the dots spawn inside of the circle object but the only problem is it’s in the same position as the pink paddle object. Any solutions???
I want the yellow dots to spawn at a random position inside of the blue circle, away from the pink paddle.
I managed to spawn the yellow dots randomly around the circle and not on the pink paddle position, now how do i spawn the yellow dots only inside of the blue circle and not outside it???
Here’s my code, the target Transform is the circle and not the paddle.
public Transform target;
public GameObject dotPrefab;
[SerializeField] private GameObject newDot;
Collider2D col;
private void Start()
{
col = target.GetComponent<Collider2D>();
}
private void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
newDot = Instantiate(dotPrefab);
newDot.transform.position = target.transform.position + new Vector3(Random.Range(-col.bounds.max.x, col.bounds.max.x), Random.Range(-col.bounds.max.y, col.bounds.max.y));
}
}
