- Newest
- Most votes
- Most comments
It seems like the answer is, you can't... directly? The Actor system isn't setup to accept the new AZ::Entity. It looks like the View system has been hacked a bit to implement views for Entities/Components, but not much else regarding gameplay systems. I'd imagine that there will be an actor component or something, instead of having your Entity inherit from IActor.
Researching further, it seems the Entities do nothing (I should say, no gameplay logic) but contain Components. I had problems inheriting from Entity, since you can't access framework components (friend relationship with only the Entity class.) And when you instantiate an Entity manually through GameContextBus or EntityBus, they are activated immediately, without the ability to add components; unless you want to activate, deactivate, create components, activate. Then it gets added to the root slice? I'm not clear on that one, but I don't think that's where it should be?
So, from what I understand, the work flow currently should be to add an Entity and Components in the Editor, save it as a dynamic slice file. Then in the code, instantiate the slice file? It's almost like Amazon has gone out of their way to make it inconvenient to create Entities by code. I'm new to C++ so take this all with a grain of salt. I could be missing the big picture.
At the moment to use all the tools to make a game, you will be relying on the old Entity / GameObjects and extensions system. Which will all be changed, and need to be recoded when Amazon implements the new system. Unless you're impatient and have time to re implement the functionality of these singleton systems.
Please weigh in if I'm missing the mark completely!
I think the controller isn't attaching to the actor entity, as you said. Do you know the proper way to attach a component to an entity that was created by C++? I'm creating the actor on-the-fly when TestGameRules::OnConnect() is called.
I did as you said, inserted a component entity in the level with the editor, and assigned the custom PlayerController, and a mesh. Activate() is still not being called. The Controller is derived from AZ::Component.
It's a bit frustrating, having Component/Entity classes in AzCore:: and CryAction::. Since the actor system is using IEntity, and the component is using Entity. It's not very straightforward, and it a bit confusing.
Now I'm a bit more confused... the MultiplayerProject comes with a PlayerController, and it doesn't seem like it's used either. I can't find a reference to it anywhere. Can someone explain to me how a component like this is supposed to be initialized through C++?
Maybe the component isn't attached to an entity? Create an entity in an empty level by right-clicking the terrain then selecting Create Component Entity. The Entity Outliner should open (or open it), and select the entity (probably called Entity1). In the Entity Inspector, click the Add Component... button, then select the component you want to attach to it from the list. The Activate() function in the component should get called.
If not, maybe the component has a dependency that is not present? From [1]: "Called when the owning entity is being activated. The system calls your component's Activate() function only if all dependent or required services are present. Your Activate function is always called after any components that it depends on. In addition the component makeup of an entity never changes while the entity is active, so it is safe to cache pointers or references to other components on the entity in performance-critical situations."
Or maybe PlayerControllerComponent is not derived from AZ::Component as in the example? (Although how that would compile is another question). From [1]: "Every component must include AZ::Component somewhere in its inheritance ancestry."
If it's none of those, we can investigate further!
It's the same class as in the MultiplayerProject example, with new UUID and different namespace to match my project. The internal OnTick() is a little different but, other than that it's exactly the same. The funny thing is, I can't find anywhere in the MultiplayerExample that this PlayerController is used and Activated either...All the Input controls seem to be coming from Flowgraph, however it's there in the code.
This answer was priceless for me. After around 10 days of tinkering I also came to same conclusion. But I really didn't trust my own judgement until I saw your answer.
Thank you mate. Seriously.
This post is closed: Adding new answers, comments, and votes is disabled.
Relevant content
- Accepted Answerasked 2 days ago
- asked 6 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago