I’m wondering if somebody can give me a mini-lecture on simulating huge instances of objects. I’ve posted about this on twitter and got some promising ideas, but am yet to really come up with something I can get my teeth into.
I’m attempting to make a very simple heat-tracking missile of some kind. The behaviour of the missile is extremely simple and mimics a ‘Fire-And-Forget’ style behaviour. It simple scans ahead of itself in a cone shape, finds all actors with a certain actor component I’ve created (GameObjectComponent), and reads a ‘Heat’ float variable, a ‘Team’ number and it’s current distance to the target. Based on this, I just want the missile to pick the best target in it’s field of view and home in on it.
The logic of adjusting velocity and homing in on a target is relatively simple and Epic even gives an example of it in their own code. The hard part is efficiently picking a target to home in on. My current method is pretty basic and not very efficient at all, I have a huge (invisible) collision cone out of the front of the missile that looks for overlaps, and from that gets all of the actors with a certain Actor Component and gets the variables, it sorts through them all and picks one to home in on.
The thing is, it’s acceptable for say 1-10 missiles, but anything more than that and I start hitting slow-downs. The worst part is that because I’m using a collision overlap to find targets, it’s very unscalable, so the more missiles I add, the worse it’s going to get. I’m basing the game off of a much older game from around 1999, and although it doesn’t have the same complex physics/graphical overhead of Unreal, it still manages to simulate several hundreds (possibly thousands) of these missiles at once, and accross a multiworld-lockstep style network connection too.
I’m not massively experienced with programming but I know enough to know that I need some kind of very fast look-up for the missiles to be able to find a target really quickly and fluidly. I want to be able to simulate hundreds if not thousands of these things without batting an eyelid, so how would I go about setting up an efficient system for this? I need it to work in multiplayer, and in the game I’m basing it off of, the missiles don’t seem to follow any kind of group/leader behaviour, they really act like individual missiles.
I expect I might have to get my hands dirty with some advanced programming techniques to do this, like storing an array of all of my custom ActorComponents in the world, maybe in a quad-tree (no idea how to implement that) to look them up based on distance etc. I’ve just got no idea where to really start, and what I should be looking at, so any help at this stage is most welcome!