AActor, UObject, or UStruct for the units in an rts game?

Understood.


@SophiaWolfie in case you are interested here is a working project you can download: GitHub - thomasfaget/WestWorldWithMessaging: AI project.

if you understand I have misinformed please don’t mark my post as solution. :innocent: I have a lot of research to do.

1 Like

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.

1 Like

You are free to do what you want with your game, we can’t force people to learn i guess, but at least other readers are warned.
Good luck

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.

2 Likes

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.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.