I have a space ship pawn set up that includes a static mesh, a spring arm, a camera, and a particle system to emit dust around the player. I have also set up input bindings to allow the pawn to freely move around a space scene. This is the default pawn for the game mode that the player controls. I understand that the PlayerController is responsible for gathering the actual input from the keyboard, and translating that to the actions defined in the Input settings.
My question is, how does this work when I want the AI to move a ship through space using the same pawn. Is the AIController responsible for triggering the actions defined in the Input settings? What happens with the spring arm, camera and the particle system? I don’t want the AI space ship to have a camera and a particle system. Does it even need to be the same pawn? How do I keep this separate?
So in short, is the intention to reuse a Pawn blueprint for both AI and humans, or should they be separate?
I personally would use a player controller that sent all the commands to the pawn. Then you can make a child BP from the pawn and override anything you don’t need. They have an AI controller that possesses this new child pawn. I am not sure if that is the most efficient way to do it but I know it works as I have done it many times. I hope that helps. To remove the particle system from the AI’s pawn I think you can put it in the construction script to remove that component. As for the camera and spring arm you might be able to do the same, but I am not sure on those last two points.
Hi Imonin, thanks for you swift reply! I am not sure I understand completely. I guess what I am trying to figure out is if the best practice is to have a single generic Pawn derivative that suits both AI and humans, or if I should have a PlayerPawn (with camera and particle system) and a AIPawn (which does not have a camera and particle system). Do you have an example of what you mean?
Sorry, I was in a hurry earlier. From what you described the following is what I would do:
I would created a BP with all of the functionality that ALL spaceships needed. This would include movement, damage and the like. It would also include components that ALL ships would need such as static/skeletal mesh, possible audio and effects that they would all have. After this was created I would make child BPs based upon this one. I would make a child BP for the players ships that I would then add all the components that only the player ships would need such as cameras and the particle effects you mention. I would also make a child BP off of the first BP for the AI ships. This BP would have all the stuff that only the AI would need.
So for this you would have 3 blueprints one I would call the parent or master that has all the stuff everyone needs, a player BP that has stuff that only the players need and a AI BP that has only stuff the AI needs.
A child blueprint allows you to access everything the parent does, as well as its variables. I use parenting all the time for my pawns. For this set up you wouldn’t use the “master” or “parent” BP in your levels at all. You would only use the children derived from the parent.