dimanche 21 avril 2019

How to instantiate prefabs randomly one next to each other between vector double range

I am trying to instantiate 6 prefabs from an array at random positions within a range. I can instantiate the prefabs randomly as needed the problem lies in their positioning I need them one next to each other but the vector positions between them are very small

X. -0.37 to 0.233 Z. 0.268 to -0.041

var obj = Instantiate(CharToPrefab[randomChar]);

        obj.transform.position = new Vector3(
            Random.Range(-0.37, 0.233),
            -0.1741,
            Random.Range(0.268, -0.041)
            );

I expect the prefabs to instantiate anywhere between those points, the errors I recieve are that I cannot convert double to float but I need the prefabs between those two small points as the game relies on leap motion technology in which the play in unable to reach outside those boundaries that I have created for my game play view.

Is there an alternative way to have these cube prefabs positioned where needed?




Aucun commentaire:

Enregistrer un commentaire