Forum rules - please read before posting.

Split Screen Shader and Hotspot

Hi everyone

I'm working on a new project and have a bit of a weird idea for the camera that I'm trying to get up and running.
I've looked through the forums and the manual but couldn't quite find anything that helps with the problems I'm currently coming across. I don't know if this idea is possible within the adventure creator framework, or if I'm just entirely misunderstanding something.

My idea is a game rendered from two different camera views simultaneously. After discovering that AC had a split screen system built in it seemed perfect. There are three main issues that I'm currently having with the system however.

  1. Shaders

I'm planning on applying shader filters to the cameras and at different points will require a different filter on each camera. From my current understanding AC only sees one camera as the "main" camera at any given point. Because of this the two "reference" cams created from the Game Editor can have a filter applied to them and it even runs during gametime but as soon as a reference camera is assigned to "main" camera it seems like the settings of "Main Camera" override anything applied to the reference cam. This could be skirted around by just having the filter applied to the reference of the cam that isn't main (e.g right hand side) and then applying the filter directly to the main cam itself for the other one. The problem with that workaround ties into the second issue I'm having.

  1. Hotspots

Creating a couple of tests hotspots within the bounds of both cameras it seems that I'm only able to interact with the hotspots within whatever is assigned as "Main Camera". For the gameplay I'm hoping to have the player be able to interact with both screens as each will have different elements of the game on them. As it now if the Left hand side is assigned as the "Main Camera" then I'm able to interact with its hotspots but not the right. Within an actionlist I can change the right hand side to be "Main Camera" but this would require some creative design around what actions would swap the camera and when the "Main Camera" is switched to the right hand side any filter applied to the reference camera called on the right hand side is wiped as above. Is there a way to have both cameras / views be interactive with hotspots simultaneously? and is there a way to be able to keep the different filters for each view?

  1. Menus

There are some things in the game that feel best done with menus e.g the pause menu. By default AC seems to want to put a menu right in the centre (where the divider line is for the two cameras) my preference would be to have menu elements centered within one specific camera view (e.g the left hand side camera). Aligned doesn't seem to really have anything that would help with this, I'm a little worried about using Manual Alignment and how that might look on different screens / scaling issues with screen sizes and the other options like Follow Cursor and On Hotspot don't seem quite right for what I'm trying to do either. Any advice on how to go about this menu placement too would be greatly appreciated

Thanks in advance

Comments

  • I'm planning on applying shader filters to the cameras and at different points will require a different filter on each camera. From my current understanding AC only sees one camera as the "main" camera at any given point.

    Normally, AC will disable all GameCameras in the scene and only use them as positional references for the MainCamera - which is the only one that actually performs rendering. If you wanted a shader filter to be applied at this time, it would go on the MainCamera.

    When in split-screen mode, AC will enable the GameCamera that is used to render the half of the screen that isn't assigned as the Main Camera. In this case, you can assign a separate shader filter to this GameCamera and have it take effect.

    As this is purely visual, however, I would focus on the interactivity issue first.

    For the gameplay I'm hoping to have the player be able to interact with both screens as each will have different elements of the game on them.

    Only the screen-half assigned to the Main Camera can be interactive - the other is visual only.

    You could feasibly involve a script that switches which half is assigned to the Main Camera, based on the cursor's position - so that when the cursor enters that screen's half, the MainCamera becomes active on that side of the screen.

    What proportion and orientation does the split-screen effect involve? Any screenshots that illustrate the situation will help clarify the setup.

    By default AC seems to want to put a menu right in the centre

    Menus with Source set to Adventure Creator are rendered in game-window space - not in camera-space. To have them render in camera space, you'll need to switch to Unity UI, and set the Render Mode to Screen Space Camera. AC will automatically assign the Canvas's "World Camera" field to the MainCamera at runtime.

  • Hi Chris, thanks for the swift response

    I think I mostly had it but your explanation has cleared up how the camera system works for me. That said I think you're right that for now getting the interactivity correct is the bigger focus.

    Being able to change which side is considered the "Main Camera" based on cursor position would be ideal if possible. I've attached some screenshots (hopefully they work) to this post showing the current example of layout and the split camera action. I'm going for a fairly basic left hand/right hand vertical split although at this point looking at making one camera (the left currently) slightly bigger as more of the game will take place here. Currently the left is at 0.58 with the right at 0.4


    I would also like certain points in the game to utilize a singular traditional camera view, right now I have this working with a hotspot use calling the Camera Switch function followed by using the Camera Split-Screen function again but ticking "just disable previous?" this seems to work, is this a reasonable way to go about this and would modifying a cursor script break the single camera use or would this still be ok?

    I've noticed that adventure creator can work with unity UI before but haven't delved too much into it being able to work within the confines of adventure creator and not wanting to accidentally break something if I could avoid it. That said using Unity UI and setting the Render Mode to Screen Space Camera sounds like the way to go about this so I'll definitely start researching and trialing this once I can get the cameras working properly

  • Thanks for the details - is the 0.58/0.4 split consistent for all such times?

  • Yeah every split will be both in the same orientation (vertical left/right) and at 0.58 left /0.4 right

  • edited June 2022

    To allow for this, I will need to make some changes to AC itself - expect these to be included in the next release.

    Once made, you should then be able to make use of this script to have the MainCamera dynamically swap over to the same side of the screen that the cursor is over:

    using UnityEngine;
    using AC;
    
    public class DynamicSplitScreen : MonoBehaviour
    {
    
        private Rect otherCameraRect;
        private bool isInSplitScreen;
    
        private void OnEnable ()
        {
            EventManager.OnCameraSplitScreenStart += OnCameraSplitScreenStart;
            EventManager.OnCameraSplitScreenStop += OnCameraSplitScreenStop;
        }
    
        private void OnDisable ()
        {
            EventManager.OnCameraSplitScreenStart -= OnCameraSplitScreenStart;
            EventManager.OnCameraSplitScreenStop -= OnCameraSplitScreenStop;
        }
    
        private void Update ()
        {
            if (isInSplitScreen)
            {
                Vector2 mousePosition = KickStarter.playerInput.GetMousePosition ();
                Vector2 mousePositionScreen = new Vector2 (mousePosition.x / ACScreen.width, mousePosition.y / ACScreen.height);
    
                if (otherCameraRect.Contains (mousePositionScreen))
                {
                    KickStarter.mainCamera.SwapSplitScreenMainCamera ();
                }
            }
        }
    
        private void OnCameraSplitScreenStart (_Camera _splitCamera, CameraSplitOrientation _splitOrientation, float _splitAmountMain, float _splitAmountOther, bool _isTopLeftSplit)
        {
            if (_splitOrientation == CameraSplitOrientation.Overlay)
            {
                return;
            }
    
            isInSplitScreen = true;
            otherCameraRect = KickStarter.mainCamera.GetSplitScreenRect (false);
        }
    
        private void OnCameraSplitScreenStop (_Camera camera)
        {
            isInSplitScreen = false;
        }
    
    }
    
  • That's above and beyond. Thank you Chris I appreciate it.

    I'll wait for the next update and then include this script let you know how I get on

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.