This is my doubt:
I have a Level Map like the image attached, with 6 desired places for ammo to be picked.
I want to place only 3 ammos but in different places (randomly between my desired places) every time the level is played.
My initial approach is:
Every desired place is an empty GameObject with his Transform.position (6 in this example).
I store every empty GameObject in a Transform Array (to get the values).
I specify the number of ammo prefabs I want to place (3 in this example).
The ammo prefabs are instantiated randomly according the Array, preserving the Position, Scale and Rotation values of the empty GameObject.
This is my code:
using UnityEngine;
using System.Collections;
public class RandomPositions : MonoBehaviour {
public Transform[] DesiredPositions;
public int NumberOfAmmos;
public GameObject Ammo;
Vector3 GeneratedPosition()
{
foreach (Transform POS in DesiredPositions) {
// ?????? //
// I'm blocked //
// ?????? //
}
}
void RandomAmmo()
{
for(int i = 0; i < NumberOfAmmos; i++)
{
// ????? //
Instantiate(Ammo, GeneratedPosition());
// ????? //
}
}
void Start () {
RandomAmmo ();
}
}
Now I’m blocked.
Anyone can help me or has a better solution? (In c#, please).
Thanks.