For example, the general in Three Kingdoms 10, does not need to appear in the scene, but also has his own logic.
Now I inherit UObject, but I find it inconvenient to initialize parameters. There is no suitable method for BeginPlay, so I need to write an Init method by myself, and then call it after Newobject().
I find the AInfo class, but see the description of the base class for the configuration file.
Please ask me how to implement such a system as Three Kingdoms 10 Martial generals?
I think you mean to ask “what class should objects that don’t need to appear in the scene inherit?”
If that is the question, the answer is likely AActor or AInfo. AActor does provide objects with a position in the scene, but it’s very common (and often recommended) to subclass AActor or AInfo even for objects that aren’t visible.
For exampe, the APlayerController is an AInfo, as is the AGameModeBase (!)
I don’t know what the Generals do in the game, but it sounds like you want to make them some kind of AInfo that get added to the game, and maybe there’s some kind of AController that knows to communicate with these guys to take orders?
Another option would be to subclass ActorComponent and add these components to the PlayerController. This could be helful if the role of the generals is mainly to provide additional UI and advise to the player. You can then find the appropriate General for a given Player by finding its PlayerController and look up the component there.
I mean, there are about 1,000 characters, and each character has its own logic of behavior.These characters do not appear in the scene except in exceptional circumstances.It only appears on a few lists.After each turn, the character follows the logic that has been written.
I’m using UObject now,but it’s inconvenient.
Should I extend the AInfo class to implement the logic?
I see the AInfo class described as the base class of the configuration file, but it doesn’t feel right.
I reorganized the language in the above reply, and hopefully you can see it a little bit more clearly…I’m sorry
AActor doesn’t seem like a good fit, even if it is set to be invisible, there is still an additional performance cost.
ActorComponent is not a good fit; these roles don’t look like components.
AInfo… Look at the description information, is as a configuration class base class, feel is not very appropriate…