- Home /
Collision causing performance to drop
When I took out the coin += 1; (etc) the frame rate was normal. How can I make it so that I can optimize frame rate and performance on mobile?
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "coin")
{
coin += 1;
coinRes += 1;
}
}
keep in $$anonymous$$d that this is a full on game with much more code, I just need to know what I can do to optimize performance
adding a single integer should not slow down your game at all, you will have to show the rest of your code so we can figure out what is going on. I don't think there is anyway to optimise what you have shown. How many collisions are happening? $$anonymous$$any collisions can slow down performance. Also there is a profiler to see what is causing the issue.
Well everything that is happening with the coin collection is I add the integer value, then the text display for the coin is equal to the integer value. The actual coin goes inactive in the hierarchy on collision. That is pretty much everything that is going on with the coin collection.
Can you post the full script? $$anonymous$$aybe check the profiler and see if you can ascertain what's going on?
Where's the script for the deactivation?