"unity3d invector expand fsm controller" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "unity3d invector expand fsm controller" answered properly. Developers are finding an appropriate answer about unity3d invector expand fsm controller related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like unity3d invector expand fsm controller. Enter your desired code related query in the search bar and get every piece of information about C# code related question on unity3d invector expand fsm controller. 

unity3d invector expand fsm controller

By Crescent FreshCrescent Fresh on May 11, 2020
using UnityEngine;

namespace Invector.vCharacterController.AI
{
    /// <summary>
    /// This is a simple example on how to expand the AI Controller by creating your own methods, you don't need to modify the core scripts
    /// Simple expand the Interface and the Controller here, and you can create new FSM Custom Actions & Decitions to call your custom methods
    /// </summary>    

    // First create a Partial Interface vIControlAI to expand access to the FSM with new methods and variables
    public partial interface vIControlAI
    {
        // Here we created a variable that can be access from my New Action
        GameObject customTarget { get; }
        bool _moveToTarget { get; }

        // Declaring the new Method that will be implemented below
        void MoveToTargetExample();
    }

    // Now create a Partial class vControlAI and implement the new methods and variables from our Interface above 
    public partial class vControlAI
    {
        // The vEditorToolbar will display a new tab in your AI Controller Inspector
        [vEditorToolbar("Custom Properties")]

        // This variable will appear in the new Tab 'Custom Properties'
        [vHelpBox("Check the script 'vControlAI_ExpandExample' to see how you can expand the controller by creating your own methods and variables", vHelpBoxAttribute.MessageType.Info)]
        public GameObject myTarget;

        // Just a bool so we can test the method, check true via inspector to make the controller MoveTo the target assigned
        public bool moveToTarget;

        // We need to create the bool again so we can pass this information to the FSM 
        public bool _moveToTarget { get => moveToTarget; }

        // This is a simple example for the FSM to have access to the variable myTarget
        public GameObject customTarget { get => myTarget; }


        // Make it public so you can call it when you create a new FSM CustomAction
        // To create a new FSM CustomAction open the FSM Window > FSM Component click on the '+' button > Action > New Action Script
        // Then simple call your method in the DoAction like this:
        // fsmBehaviour.aiController.MyNewMethod();
        public void MoveToTargetExample()
        {
            // Simple example to move the controller to a specific position set via inspector     
            
            if(myTarget != null)
            {                
                // Here we simple call the method MoveTo from the original vControlAI script

                MoveTo(myTarget.transform.position);
                Debug.Log("Controller Calling 'MoveTo' ");
            }
            else
            {
                Debug.Log("Controller Calling 'MoveTo' but a 'myTarget' is not assigned");
            }
        }
    }
}

Add Comment

0

All those coders who are working on the C# based application and are stuck on unity3d invector expand fsm controller can get a collection of related answers to their query. Programmers need to enter their query on unity3d invector expand fsm controller related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about unity3d invector expand fsm controller for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of unity3d invector expand fsm controller while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "unity3d invector expand fsm controller". Visit this developer's friendly online web community, CodeProZone, and get your queries like unity3d invector expand fsm controller resolved professionally and stay updated to the latest C# updates. 

C# answers related to "unity3d invector expand fsm controller"

View All C# queries

C# queries related to "unity3d invector expand fsm controller"

Browse Other Code Languages

CodeProZone