Mostly I have read that you should create each of game objects or entities it’s own BasicEffect or Custom Effect as for example if I have 500 bullets as shown in the image below if I will create each of them it’s own BasicFX/CustomFX when the bullets elapse it’s life time I need to destroy 500 BasicFX/CustomFx ?
Against if I will only use single BasicFX/CustomFX and apply the appropriate properties on render time to the global single BasicFX/CustomFX then I don’t need to destroy any effects.
But Is there any long run side effect if I will just use single BasicFX/CustomFX for all of my game objects ?
To the title question: no.
Mostly I have read that you should create each of game objects or entities it’s own BasicEffect or Custom Effect as for example if I have 500 bullets as shown in the image below if I will create each of them it’s own BasicFX/CustomFX when the bullets elapse it’s life time I need to destroy 500 BasicFX/CustomFx ?
Everything about this is so wrong that I hope you’re just misinterpreting things you’ve read and not that that’s what they’ve actually said.
They might all reference an effect, but it may very well be the same effect for all of them - it certainly should not be many instances of the same effect.
1 Like
Ah ha! that’s a relief no need to modify my engine : - D Thanks for clarity Sir Acid ^_^y
It’s not your main question but as a general principle it is bad design practice to be regularly creating and destroying hundreds of objects (the bullets in your example) as you’ll more than likely run into garbage collection issues.
Consider creating a ‘pool’ of bullets instead, removing objects from the pool when needed and returning them when done. This way they never get destroyed and you don’t run the risk of clogging up the garbage collector.