|
I am creating a game which the player collect coins and keeps going up. I need this coins to disappear when the user is too far. What I am doing right now is adding a component to the coins with the following: Since the profiler showed that it was called a lot I changed this to the following: While testing this second implementation it felt slower (Nothing is said in the profiler). Do you think there is a better approach?
(comments are locked)
|
|
First off, I'm unfamiliar with the Object Pool Manager use, but for each one, why not just use Destroy(gameObject)? Also, try testing out a single script, possibly a Coins script or something, iterating through the coins each frame, instead of each coin having a script itself that is called every frame. No matter what, you'll need to check every frame for each coin, it just may be easier to do something like this: The reason for the second list thingy is because you can't be iterating through a list and adjust its members. This is just a rough guess and may not suite you, but it would keep all your necessary code in one spot for coin removal. También, si nunca has usado un List antes, tienes que incluir "using System.Collections.Generic" al principio de su code.
May 16 '12 at 08:13 PM
Befall
(comments are locked)
|
