Forum rules - please read before posting.

Compile errors after AC update

Hi

I recently updated AC to 1.71.4, but now I am getting compile errors with a script that I use that integrates with Adventure Creator player characters.

The Opsive TPC Adventure Creator Controller Bridge script produces these errors.

Assets/Third Person Controller/Integrations/Adventure Creator/AdventureCreatorControllerBridge.cs(86,70): error CS0122: AC.Char.CanBeDirectControlled() is inaccessible due to its protection level

and

Assets/Third Person Controller/Integrations/Adventure Creator/AdventureCreatorControllerBridge.cs(76,73): error CS1540: Cannot access protected member AC.Char.CanBeDirectControlled() via a qualifier of type AC.Char. The qualifier must be of type Opsive.ThirdPersonController.ThirdParty.AdventureCreator.AdventureCreatorControllerBridge' or derived from it

I am thinking it has something to do with the private variables, but I might be wrong here. Tried to change to public, same errors.

Unity 2018.4.4f1
AC 1.71.4

Thanks

Comments

  • This is the UCC integration script from the wiki?

    AC's UCC integration has been updated to a dedicated package - grab it from the Downloads page.

  • Thanks for the link but the script I am having trouble is for the old version of TPC ( version 1.3.11 that is deprecated) the one before they upgraded to UCC. I never upgraded TPC to UCC because I have too many custom abilities that would not work with the new version.

    Will this package still work ?

  • That'd be a question for Opsive, but I'd imagine it'd need some tweaking.

    The original script issues you're posting, though, should be solvable by making the CanBeDirectControlled function (in both Player.cs and Char.cs) public. If there's still a compilation error, it should be different.

    I'm not sure where your script is coming from, but if you'd like to post it I can take a look and see what else might be wrong.

  • Thanks Chris. Here's the original

        using UnityEngine;
        using AC;

        #if !(UNITY_5_1 || UNITY_5_2 || UNITY_5_3)
        using UnityEngine.SceneManagement;

        #endif
        namespace Opsive.ThirdPersonController.ThirdParty.AdventureCreator
        {
        /// <summary>
    
        /// Acts as a bridge between the Third Person Controller and Adventure Creator. Assign this component to the same component that
    
        /// the Adventure Creator Player component is assigned to.
    
        /// </summary>
    
        public class AdventureCreatorControllerBridge : MonoBehaviour
    
        {

        [Tooltip("Should the character initialize with the camera upon start?")]
        
        [SerializeField] protected bool m_InitWithCameraOnStart = true;

    
        // Component references
        
        private Char m_AdventureCreatorController;
    
        // Internal variables
        private bool m_CanBeDirectControlled;
    
        /// <summary>
        /// Cache the component references.
        /// </summary>
         private void Awake()
        {
            
        m_AdventureCreatorController = GetComponent<Char>();
        
        }
    
        /// <summary>
        
        /// The component has been enabled.
        
        /// </summary>
         private void OnEnabled()
        
        {
            
        UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneLoaded;
        
        }

    
        
 /// <summary>
        
        /// The component has been disabled.
        
        /// </summary>
        
        private void OnDisabled()
       
         {
            
        UnityEngine.SceneManagement.SceneManager.sceneLoaded -= SceneLoaded;
        
        }

    
        /// <summary>
        
        /// Initialize the enabled state of the controllers.
        
        /// </summary>
        
        private void Start()
       
         {
            m_CanBeDirectControlled = !m_AdventureCreatorController.CanBeDirectControlled();
                         Initialize();
        
        }

    
        /// <summary>
        
        /// Initializes the controller and camera components to point to the new Adventure Creator character.
        /// </summary>
    
        private void Initialize()
       
         {
            
        UpdateEnabledState();

            
    
        // Assign the character to the camera after the character has been spawned by Adventure Creator.
            var cameraController = GameObject.FindObjectOfType<CameraController>();
            
        if (m_InitWithCameraOnStart && cameraController != null) {
                
        cameraController.Character = gameObject;
      
          }
        
        }

    
        /// <summary>
        
        /// Enable or disable the controller handler based on if the Adventure Creator controller can be directly controlled.
        
        /// </summary>

    
        private void Update()
       
         {
           
         if (m_CanBeDirectControlled != m_AdventureCreatorController.CanBeDirectControlled()) {
                UpdateEnabledState();
            
          }
        
        }

    
        /// <summary>
       
         /// The direct controlled status has changed so the controller's enabled state should reflect that change.
        /// </summary>
    
        private void UpdateEnabledState()
        
        {
            
        var canBeDirectControlled = m_AdventureCreatorController.CanBeDirectControlled();
            
        if (m_CanBeDirectControlled != canBeDirectControlled) {
                
        m_CanBeDirectControlled = canBeDirectControlled;
                
        m_AdventureCreatorController.enabled = !canBeDirectControlled;
                EventHandler.ExecuteEvent(gameObject, "OnAllowGameplayInput", canBeDirectControlled);
            
         }
        
        }

    
        #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3

        /// <summary>
        
        /// Callback when a new scene has been loaded.
        
        /// </summary>
        private void OnLevelWasLoaded()
        
        {
            
        SceneLoaded();
        
        }

        #endif

    
        /// <summary>
        
        /// Callback when a new scene has been loaded.
        
        /// </summary>
    
        {
            
        SceneLoaded();
        
        }

    
        /// <summary>
        
        /// Adventure Creator's character persists throughout the scenes using DontDestroyOnLoad. Force the reinitialization of the necessary variables.
        
        /// </summary>
        
    
        private void SceneLoaded()
       
         {
            
        m_CanBeDirectControlled = false;
            
        EventHandler.ExecuteEvent(gameObject, "OnAllowGameplayInput", false);
            
        Initialize();
       
          }
    
         }

        }

    
  • The approach this takes isn't ideal, because it works by disabling AC's Player component.

    I've made a couple of tweaks but I'm without the same asset so it may need a little more tweaking:

    using UnityEngine;
    using AC;
    using UnityEngine.SceneManagement;
    
    namespace Opsive.ThirdPersonController.ThirdParty.AdventureCreator
    {
    
        public class AdventureCreatorControllerBridge : MonoBehaviour
        {
    
            [SerializeField] protected bool m_InitWithCameraOnStart = true;
    
            private Char m_AdventureCreatorController;
            private bool m_CanBeDirectControlled;
    
    
            private void Awake ()
            {
                m_AdventureCreatorController = GetComponent<Char>();
            }
    
            private void OnEnabled ()
            {
                UnityEngine.SceneManagement.SceneManager.sceneLoaded += SceneLoaded;
            }
    
            private void OnDisabled ()
            {
                UnityEngine.SceneManagement.SceneManager.sceneLoaded -= SceneLoaded;
            }
    
            private void Start()
            {
                m_CanBeDirectControlled = !CanBeDirectControlled ();
                Initialize();
            }
    
            private void Initialize ()
            {
                UpdateEnabledState();
    
                // Assign the character to the camera after the character has been spawned by Adventure Creator.
                var cameraController = GameObject.FindObjectOfType<CameraController>();
    
                if (m_InitWithCameraOnStart && cameraController != null)
                {
                    cameraController.Character = gameObject;
                }
            }
    
            private void Update()
            {
                if (m_CanBeDirectControlled != CanBeDirectControlled())
                {
                    UpdateEnabledState();
                }
            }
    
            private void UpdateEnabledState()
            {
                var canBeDirectControlled = CanBeDirectControlled ();
    
                if (m_CanBeDirectControlled != canBeDirectControlled)
                {
                    m_CanBeDirectControlled = canBeDirectControlled;
                    m_AdventureCreatorController.motionControl = (canBeDirectControlled) ? MotionControl.Manual : MotionControl.Automatic;
                    EventHandler.ExecuteEvent(gameObject, "OnAllowGameplayInput", canBeDirectControlled);
                }
            }
    
            private void SceneLoaded()
            {
                m_CanBeDirectControlled = false;
                EventHandler.ExecuteEvent(gameObject, "OnAllowGameplayInput", false);
                Initialize();
            }
    
            private bool CanBeDirectControlled ()
            {
                if (KickStarter.stateHandler.IsInGameplay () && KickStarter.settingsManager.movementMethod != MovementMethod.PointAndClick)
                {
                    return true;
                }
                return false;
            }
    
        }
    
    }
    

    I'd still recommend contacting Opsive to ask about compatibility with the new integration, though - they were involved in producing it as well.

  • Thanks, I can work with this. Looks more tidy. I'll change CanBeDirectControlled functions in Char and Player to public first, and see what happens. Thanks again :)

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.