+ 4

Unity C# Question

I have a thing I'm working on, which starts with 100 coins layed out when the game starts. I want to instantiate them, but it isn't working right. I want this basically ○○○○○ ○○○○○ ○○○○○ ○○○○○ ○○○○○ So I wrote this for(int i=0; i<10; i++){ for(int n=0; n<10; n++){ loc = new Vector3(8.0f+i, 10.0f, 5.0f+n); instantiate(coin, loc, Quatarian.identity); } } Which puts a coin everywhere I want one, works great, with 1 flaw. it spawns 2 coins in each spot. any idea why?

4th Mar 2018, 12:24 AM
LordHill
LordHill - avatar
3 Answers
+ 7
Looks okay. Is there any chance the method used to instantiate the objects was called twice? Perhaps check with the debugger.
4th Mar 2018, 1:06 AM
Rrestoring faith
Rrestoring faith - avatar
+ 3
confirmed. I put the script on 2 objects. All good
4th Mar 2018, 4:01 PM
LordHill
LordHill - avatar
+ 2
That's what I am thinking. maybe I accidentally stuck the script on multiple objects. I'm going to have to check
4th Mar 2018, 1:07 AM
LordHill
LordHill - avatar