I must add that doing/reinventing things yourself can be really fun!
But if you are hours deep into trying to make something work that’s just out of your expertise it’s probably a good idea to check if there’s a solution built into the engine instead of banging your head against a wall