Topic: How do I disable default camera and use custom camera?

I have a custom camera I am trying to use. I have written this code but throws errors. I just need to disable the default camera for UFE 2 so that I can use my own. Here is the code I currently have:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FPLibrary;
using UFE3D;

public class CameraOverride : MonoBehaviour
{

    public Camera splitScreenCam;
    public Camera ufeCamera;

    void Start()

    {
        UFE.OnGameBegin += OnGameBegin;


    }


    void OnGameBegin(CharacterInfo player1, CharacterInfo player2, StageOptions stage)
    {
        if (player1 != null && player2 != null)


            ufeCamera.SetActive(false);

        splitScreenCam.SetActive(true);


    }



}

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

can you tell use the errors?

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

Here are the errors.

Assets/CameraOverride.cs(22,22): error CS0104: 'CharacterInfo' is an ambiguous reference between 'UFE3D.CharacterInfo' and 'UnityEngine.CharacterInfo'

Assets/CameraOverride.cs(22,45): error CS0104: 'CharacterInfo' is an ambiguous reference between 'UFE3D.CharacterInfo' and 'UnityEngine.CharacterInfo'

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

try this

 void OnGameBegin(UFE3D.CharacterInfo player1, UFE3D.CharacterInfo player2, StageOptions stage)

Share

Thumbs up Thumbs down

5 (edited by G_Darius 2022-05-29 15:32:52)

Re: How do I disable default camera and use custom camera?

FreedTerror wrote:

try this

 void OnGameBegin(UFE3D.CharacterInfo player1, UFE3D.CharacterInfo player2, StageOptions stage)

I get these errors now using this method.

Assets/CameraOverride.cs(16,9): error CS0123: No overload for 'OnGameBegin' matches delegate 'UFE.GameBeginHandler'

Assets/CameraOverride.cs(27,23): error CS1061: 'Camera' does not contain a definition for 'SetActive' and no accessible extension method 'SetActive' accepting a first argument of type 'Camera' could be found (are you missing a using directive or an assembly reference?)

Assets/CameraOverride.cs(29,24): error CS1061: 'Camera' does not contain a definition for 'SetActive' and no accessible extension method 'SetActive' accepting a first argument of type 'Camera' could be found (are you missing a using directive or an assembly reference?)

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

You can't use SetActive on a camera Type.
You have to use enabled instead

public Camera test;
test.enabled = false;

Not sure whats going on with ongamebegin

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

I am still having trouble with overriding the stock camera and using a custom camera. Is there anyone here that can assist with a script that overrides the current camera and makes the custom camera the main camera?

Share

Thumbs up Thumbs down

Re: How do I disable default camera and use custom camera?

Try following this tutorial:
https://www.youtube.com/watch?v=wWTOuggRvgc
Should help with some coding basics if you are a bit lost.

Like UFE? Please rate and review us on the Asset Store!
Questions about the Forum? Check out our Karma FAQ.
Don't forget to check our discord channel.

Re: How do I disable default camera and use custom camera?

I ended up writing this script for this case. I've tested it and it works.
Anyone can modify it to suit your needs.

using UnityEngine;

public class UFE_2CameraRequestForG_Darius : MonoBehaviour
{
    public Camera UFE_2Camera;

    public Camera splitScreenCamera;

    // Update is called once per frame
    void Update()
    {
        if (UFE.p1ControlsScript != null
            && UFE.p2ControlsScript != null)
        {
            UFE_2Camera.enabled = false;
            UFE_2Camera.tag = "Untagged";

            splitScreenCamera.enabled = true;
            splitScreenCamera.tag = "MainCamera";
        }
        else if (UFE.p1ControlsScript == null
            && UFE.p2ControlsScript == null)
        {
            UFE_2Camera.enabled = true;
            UFE_2Camera.tag = "MainCamera";

            splitScreenCamera.enabled = false;
            splitScreenCamera.tag = "Untagged";
        }
    }
}

Share

Thumbs up +1 Thumbs down

Re: How do I disable default camera and use custom camera?

I'm doing something with the onGameBegin function and it still gives errors.

Me encontraste en un negro camino como un peregrino sin rumbo ni fe, pero la luz de tus ojos divinos cambió mi suerte por dicha y placer.