I’m making an RTS game where a solo player can see both their base and that of their AI opponent. The player needs to be able to freely interact with both sides of the split screen to select units, assign targets, and move-to locations. The player view would have some minor camera movement with WASD (no edge screen movement) while the AI would have a static camera over their base.
I know how to set up a split screen to support a second player but my goal is for the single player to be able to control both sides.
Perhaps there is a way to auto-possess the AI’s screen when a cursor overlap event is detected to provide fluid control of both sides of the screen without hard switches? How would I write that with blueprints?
Are there better implementations that I’m completely missing?
To achieve this kind of control in an RTS game where a solo player can freely interact with both sides of the split screen, you can use a combination of camera switching, cursor detection, and controlling the units based on the active camera. Here’s a basic outline of how you might approach this in Unreal Engine using Blueprints:
Camera Setup:
Set up two cameras, one for the player’s base and another for the AI’s base.
Adjust the cameras’ locations and orientations to provide the desired views.
Cursor Overlap Detection:
Use a custom Blueprint Actor or a specific class to represent your units/buildings.
Implement a cursor overlap event in this class to detect when the player’s cursor is over a unit or building.
Camera Switching Logic:
When the cursor is over a unit or building, trigger a camera switch based on the player’s input (e.g., a key press or a specific UI button).
When the camera switches, set the active camera to the corresponding one (player’s base or AI’s base).
Control Units Based on Active Camera:
Implement logic to control the units based on the active camera.
When controlling units in the player’s base, use input events related to camera movement and unit commands.
When controlling units in the AI’s base, disable camera movement input and use a static camera position for the AI’s view.
To follow up on this post, I couldn’t get the functionality I need with Blueprints and will likely have to solve the issue with C++ unless a stroke of genius hits or someone else drops into this thread with a potential solution.
My discoveries.
The camera setup wasn’t an issue. I was able to implement split-screen with no issues.
Cursor overlap is not a thing you can do in split-screen. Despite seeing two screens if you try to click on anything on the other team’s screen. Think of the extra screen as an overlay over your playspace. When you attempt to click on the opposing screen you actually click on the content below it that happens to be in your playspace but obscured by the screen.
Camera switching logic was also a no-go. I authored a blueprint that would allow me to switch possession of different camera pawns so that I could interact with the content owned by the other player. I was able to switch possession but this also switched my screen to that of the other team. I couldn’t find a way to switch possession and not switch screen sides at the same time.