Forum rules - please read before posting.

Switch to 25D Game Camera from First Person

edited February 2022 in Technical Q&A

Hello! I've tried to switch to the 25D Game Camera from the first person controller. But it doesn't work. Is it real to do it some way? Thanks.

Comments

  • I'm so sorry. My bad. I forgot to switch the movement method. There is no any problem.

  • Yes, if your movement method is First Person, then the First Person camera is switched to automatically during gameplay.

    A note about switching movement method, though: as this is a field in the Settings Manager, changes made to it at runtime will survive the ending of Play Mode. Therefore, you'll need to set this to your intended initial value when the game begins.

    This can most easily be done by assigning an "ActionList on start game" asset file at the top of the Settings Manager, containing an "Engine: Manage systems" Action to handle the change.

  • Thank you, Chris! And I have one more question. Is it real to change a background image for the 25D Game Camera some way?

  • You can change a BackgroundImage's texture by calling its SetImage function in a custom script.

  • Okay. And than I should write custom Remember script to save that texture, yes?
  • Yes. It's a bit more tricky than the tutorial, as you'll have to use AC's AssetLoader class to handle the conversion between the texture asset and a save-able string. This ought to do it, though:

    using UnityEngine;
    
    namespace AC
    {
    
        [RequireComponent (typeof (BackgroundImage))]
        public class RememberBackgroundImage : Remember
        {
    
            public override string SaveData ()
            {
                BackgroundImageData data = new BackgroundImageData();
                data.objectID = constantID;
                data.savePrevented = savePrevented;
    
                BackgroundImage backgroundImage = GetComponent<BackgroundImage> ();
                data.textureID = AssetLoader.GetAssetInstanceID (backgroundImage.backgroundTexture);
    
                return Serializer.SaveScriptData <BackgroundImageData> (data);
            }
    
            public override void LoadData (string stringData)
            {
                BackgroundImageData data = Serializer.LoadScriptData <BackgroundImageData> (stringData);
                if (data == null) return;
                SavePrevented = data.savePrevented; if (savePrevented) return;
    
                BackgroundImage backgroundImage = GetComponent<BackgroundImage> ();
                backgroundImage.backgroundTexture = AssetLoader.RetrieveAsset (backgroundImage.backgroundTexture, data.textureID);
            }
    
        }
    
        [System.Serializable]
        public class BackgroundImageData : RememberData
        {
    
            public string textureID;
    
            public BackgroundImageData () { }
    
        }
    
    }
    

    This'll require associated textures to follow the Resources save rule outlined in the Manual's "Saving asset references" chapter.

  • Okay! Thanks a lot, Chris!

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.