So I’ve started a new project with the C++ stick shooter template. I’m trying to create a camera that scrolls up constantly, so I’m making a SceneComponent, then attaching a SpringArm and a Camera to the arm. The aim is to slowly move the SceneComponent up the screen so the level falls behind. I’ve taken out the camera code from the player controlled pawn and put it in my CameraScroller class. As far as I can tell that shouldn’t be spawning the camera.
When I click play a random CameraActor is spawned with the name CameraActor1 (or 2 or 3 depending on how many times I’ve clicked the play button since launching the editor). The parent for this CameraActor is the example map. I can’t figure out how it’s being spawned or from where. I would like to set the camera from my CameraScroller class as the main camera, however this CameraActor is always the camera that is used.
Any help would be appreciated.
Did you ever solve this? I’m having the same issue
Hello Daiern and Applzor,
The CameraActor that spawns is what you’re piloting when moving around during PIE. To possess the camera that you wish to use, you would need to create a pawn or an object that inherits from pawn with that camera as a component. You would then need to set it as the DefaultPawnClass in the gamemode. Once you press play, you should automatically possess that pawn.
Hope this helps!
I have a Character using a spring arm + camera component. My Character is not present in the scene. It is spawned when I press play. It seems that this CameraActor is created before my character and it is possessed first. How do I tell it to use my Character’s camera instead of that dummy CameraActor? What is creating this CameraActor in the first place? I don’t seem to need that actor.
Hello cmarston74. It seems we both got here on this old question at the same time. Since you are here, could you perhaps help with my problem if possible? Would you be so kind to read my comment under Mathew J’s answer?
To switch cameras, get a reference to the current camera, deactivate it, and activate the camera you want to use. We use the same technique when switching from cockpit view to third-person view. Cameras are attached to the same vehicle.
If yu set the first camera to auto-actovate to false and the other to auto-actovate true. It will activate the second one by default. This is how we handle our mini-map camera. As its should never be active outside of the code handling scene captures.
Hello kbrizov. I marked the above as the answer. You need to make sure you have set the DefaultPawnClass correctly. That’s really it. Just go to the gamemode you are using (I believe it’s in the Project Settings under Maps and Modes, at work can’t check right now) and then set DefaultPawn to your Character class. If you’re using C++, you need to set the DefaultPawnClass to your Character class in the constructor.
As J said above, PIE creates a default class to use which is set in the game mode, which creates the camera.
I’ll try to help if I can. Let me see if I understand your question. You have a Camera spawning automatically and then you are manually spawning a character?
Ok. I went back and read all the comments and I think I understand what it is your trying to acheive. It’s actual pretty simple.
In your pawn class add a spring arm and camera like normal. Set the camera and spring arm to point down at your character at the height you want to be above them. During begin play, get a reference to your spring arm and set it to use absolute location and rotation. This will prevent your pawns movement from affecting the spring arm. Once you have done this you can set the spring arm location to anywhere you want, including updating it’s position to move it over the level at a constant rate.
If your spawning your character manually, set the default pawn class to none. This should prevent the system from spawning anything before you press play.
Contact me at email@example.com. We can talk back and forth easier.
Hello Daiern, thank you for spending time on my question. I already set a default pawn class. You are completely correct. However, it seems that my problem is different. For some reason when my Default pawn is spawned it’s SpringArm Component transform is completely messed up and the camera gets stuck like it’s not attached to the Spring arm. I need to investigate this strange behavior. Probably some collision settings are not right.
Thank you very much for spending time on my question cmarston74. It appears my question wasn’t clear enough, sorry for that. Some debugging later and I found out that there is a problem with my spring arm transform when my default character is spawned. This problem creates the illusion that some other camera is used instead of the one attached to the character. Pretty strange behavior. I will investigate.