Performance Advice

I’d have posted this in Answers, but it seems likely to need a discussion.

I have a project involving snow. The player can move through snowdrifts, and when they do so the snowdrifts will disappear.

Currently I have several snowdrift objects, and potentially there will be hundreds per area. I have the player check for collisions with a snowdrift, and then flip a boolean on the snowdrift object it’s currently in. Each snowdrift monitors its boolean, and when it detects the change it scales itself down (they will slowly scale up over time to reappear naturally).

Am I approaching this in the best way possible? I felt that making each snowdrift check for collision with the player would be hazardous for performance.

Thanks to anyone more experienced who can offer advice! :slight_smile:

Hi!
You are not stating what platform your aiming for. My experience is, if you don´t do something really stupid in code, what limits the performance is very seldom physics or any code for that matter.

I aim to have any project I make perform well on any platform, so take your pick!

That said, the physics on the ground objects are just triggers, and there aren’t many physics aside from checking for trigger entry/exit if that makes a difference to anyone. I would assume from my experience that checking for trigger interaction one object at time would be much less intensive than an actual physics object bouncing through the environment, which is not the case here, but I don’t know what the performance hit is if I have several hundred triggers in an area. The player only interacts with one at a time, but they are all checking their boolean status every frame.

If my approach that I described doesn’t sound potentially stupid, maybe I’m already taking the best path? I’m probing to see if there are any pitfalls I’m not aware of. I do not have the capability to test for Wii/iPhone performance at this time, but my tests for performance on PC so far seem fine.

Thank you.

First and foremost this shouldn’t a problem at this stage, you don’t appear to be doing anything massive.

However:

Depending on how your code is structured why is it changing a boolean? Wouldn’t it make sense for it simply to scale itself down?

Yeah, I think that works okay. Things seem to be performing well enough. Thanks for the sanity check guys!