that comment wasn’t me. i dont think you misinformed at all.
I think what you said makes total sense, and others said very similar things elsewhere.
thanks.
Could you explain us why it is wrong? Its your 3rd comment saying it is wrong, and all we saw here was you suggesting to use ECS, Mass, even VAT… Its a 2d game, vat will have no use. And ECS is secondary. The question is first decide to make it an actor or a struct.
@SophiaWolfie What @ads00 is refering to bad design is that by using TSharedPtr in this context does not guarantee that the struct are stored sequentialy in memory.
The approach I shared above with TSharedPtr can lead to more cache misses and potentially lower performance.
Check out the link I shared, it’s a working state design pattern and explore ECS, evaluate your specific needs regarding object lifetime management, shared ownership, and performance requirements to go for the best approach for your situation.
Ah then my bad.
So maybe instead of using TSharedPtr. I can just use a raw pointer, and manually manage the memory.
So i have one TArray Units ; Here i store the units.
Then in the unit itself i have a pointer to the enemy unit.
FUnit* Enemy. Then, when the unit dies.
I can remove the unit from the array Units. And the other pointers i can simply check if the pointer is still valid, everytime there is a combat.