Hello everyone, i have 107 golds in my scene and we need to collect them, i wrote a code but it takes the first one, but it doesn't take the second one, what can be the problem ?
Here it's :
what should i do ? If there was 10 or 15 golds, i could put 15 different scripts which are specific for each gold . But there are 107 golds, so when i did it the FPS reduces to 2 , any suggestions to make that script work?
asked May 19 '11 at 07:48 PM
Basically, what you are doing is hard coding the distance check for all of the gold objects, drastically reducing flexibility. There is one good way to do what you want to do, and it is pretty simple.
First, you need to add a BoundingSphere to your gold prefab (Components->Physics->Bounding Sphere), set the sphere to the size you want, and check is trigger on the sphere. Then, add a new behavior to the gold object. The behavior should contain the following: