Forum rules - please read before posting.

Using AC objectives

edited October 2020 in Technical Q&A

Hello
We need to add objectives to our game. We saw such thing in AC but it's not clear how to tune them to our needs.
We don't need all goals to be seen at start but to add them at certain points of a gameplay. Also, we need that finished tasks could be marked.
Now AC allows to show all objectives at once or certain type of them.
What could you advice in this situation?

Here is the example. Tasks here add during gameplay.
https://media.discordapp.net/attachments/514801471494160394/765208728928256000/unknown.png

Comments

  • Setting an InventoryBox element's Objectives to display to All will show all Objectives that are active, completed, or failed. Those that haven't been started will not be shown.

    You can begin an objective by using the Objective: Set state Action to mark it as Started. Only then will it be possible to display it in a Menu.

    For the example above, set it to All. This will list active and completed objectives.

    To then also display either a tick or question-mark icon, depending on its state, you just need a simple script to check the objective state.

    Make a Unity UI-based Menu to list your Objectives, and then attach a separate set of Image components in your UI's hierarchy - to show the desired icon.

    Then attach this script to each:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class ObjectiveIcon : MonoBehaviour
    {
    
        public int slot;
        public Sprite completed;
        public Sprite notCompleted;
        public Image image;
    
        void OnEnable ()
        {
            ObjectiveInstance[] objectives = KickStarter.runtimeObjectives.GetObjectives ();
            if (slot >= 0 && slot < objectives.Length)
            {
                if (objectives[slot].CurrentState.stateType == ObjectiveStateType.Complete)
                {
                    image.sprite = completed;
                }
                else
                {
                    image.sprite = notCompleted;
                }
            }
        }
    
    }
    

    Fill in the Inspector fields, setting the Slot value to 0 for the first-shown, 1 for the second, etc. When the Objectives are shown, the icon should then be set correctly depending on its completed state.

  • edited March 2023

    _ For the example above, set it to All. This will list active and completed objectives.

    To then also display either a tick or question-mark icon, depending on its state, you just need a simple script to check the objective state.

    Make a Unity UI-based Menu to list your Objectives, and then attach a separate set of Image components in your UI's hierarchy - to show the desired icon.

    Then attach this script to each:_

    ´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´

    I don't understand, the menu to create is an AC menu so instead of using adventure creator is to use ui - unity?

    I was using the AC objectives menu. I would like to customize with icons and I didn't understand where to use this script and what type of menu to create.

  • The script above relies on a Unity UI-based Objectives menu.

    Each of the default menus work with Unity UI - set the Menu's Source property to Unity Ui Prefab to use its Unity UI counterpart. Updating the Menu's appearance is then a case of modifying the linked Canvas prefab, ObjectivesUI.

    In what way specifically are you looking to customise the Menu?

  • In what way specifically are you looking to customise the Menu?

    similar to the one in the topic
    https://media.discordapp.net/attachments/514801471494160394/765208728928256000/unknown.png

  • You'll need to start with an Objectives UI canvas that displays a list of active and completed Objectives, and then add Images to the left of each in the Hierarchy. Give them the green "tick" sprite and line up things so that the layout is correct.

    Then, attach the script to each Image, assigning the Image component in its Inspectors, the completed / not completed sprites, as well as its slot index (first = 0, second = 1, etc). When the Menu then turns on, the Images should be updated accordingly.

  • It worked. thanks.

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.