Clone nodes for projectiles?

Hello guys, i’ve made a custom animation COntrol, and I am using it to animate some arrows shot by the player, My question is, do I have to instantiate a new arrow object with my animation control for each arrow???

lets say the player can shoot 9000 arrows, won’t it blow up the computer?

are there solutions for this? like instantiating the arrow once, and cloning it? or something like that, im just afraid that there will be too many animation controls running at once

The arrows can all share the same Mesh, but in order to set their position, each one needs to have its own Spatial. Since a control can only be added to a single Spatial, you’ll need to instantiate new controls for each arrow.

9000 arrows will not cause an explosion of course. Depending on what you do and with what hardware, it might even have decent performance.

If really you want to blow up a computer, I suggest Trinitrotoluene :slight_smile:

1 Like

hehehe, But what about calculating the maximum number of possible arrows visible at a time, and then reuse the same arrows againg and again, maybe its over kill and maybe its better the instantiate new controls because the old ones will be removed by the garbage collector?

My philosophy on performance: achieve the functionality first, then measure performance, and only then should you start trying to optimize it.

If you haven’t yet implemented the straightforward approach yet, then you haven’t measured anything, so it’s too soon for you to be trying to optimize performance.

I will say that, in my experience, scene-graph controls are lightweight objects which tend to have very little impact on performance. Your mileage may vary.

1 Like

I think your main issue would jsut be the number of objects. I believe every separate geom is a separate opengl call under the hood.

though sgold is right you should first make something that works before you try to optimize it. or else you’ll have no idea if your optimizations even matter, or on the other end, if your optimizations will be enough. Once you have it working you can see how many arrows you can afford and then poke around to find out what consumes the most time.

1 Like

i love you guys, thanks for the advices, yeah I dunno why but when i’m alone in front of my white board, i always try to think ahead and dive into the hell of performance optimization when most of the times the simplest solution is the best.

@sgold @icamefromspace