Forum rules - please read before posting.

Inventory item select

2»

Comments

  • If you want it to be based on height, yes.

    The script above locks the menu, preventing it from turning on again. You may want to remove this, or have it unlock when the mouse position is correct - it depends on the exact behaviour you want.

  • ok, so still having trouble with this, how does screen position work, what f would cover the bottom top third of the screen for example? so if mouseposition goes into the top half?

    if (mousePosition.y < Screen.height * 0.100f)
    
  • See Unity's docs on Input.mousePosition for details on what the y value represents.

    A check to determine if the mouse is in the upper third of the screen would be:

    if (mousePosition.y > 0.67f * Screen.height)
    
  • is there a way to run an action list from this script also? Found here:

    https://www.dropbox.com/sh/9qyn2p9nx08sntv/AADRc85S-Fr9OYtfaz1CQq3Za?dl=0

  • An ActionList can be run through script by calling its Interact function.

  • Thanks, what is correct scripting to check if a global variable is true please?

  • See the Manual's "Variable scripting" chapter:

    if (AC.GlobalVariables.GetVariable ("MyVariable").BooleanValue)
    {
        // Variable "MyVariable" is true
    }
    
  • thanks, how do i implement into this script so that:

    when inventory open true

    cursor detect 2/3 screen and close inventory

    if inventory open false

    cursor do not detect anything

    here is the script:

    using AC;
    using UnityEngine;

    public class CloseInventoryOnOver : MonoBehaviour
    {
        public AC.ActionListAsset actionListToRun;
        bool waitingForReset;
    
        private void Update ()
        {
            Vector2 mousePosition = Input.mousePosition;
            if (mousePosition.y > 0.20f * Screen.height)
            {
                if( !waitingForReset ){
                    PlayerMenus.GetMenuWithName ("SleepytimeVillageInventory").TurnOff ();
                    actionListToRun.Interact();
                    waitingForReset = true;
                }
                   
            }
            else{
                waitingForReset = false;
            }
        }
    } 
    
  • using AC;
    using UnityEngine;
    
    public class CloseInventoryOnOver : MonoBehaviour
    {
        public AC.ActionListAsset actionListToRun;
    
        private void Update ()
        {
            Vector2 mousePosition = Input.mousePosition;
            if (PlayerMenus.GetMenuWithName ("SleepytimeVillageInventory").IsOn ())
            { 
                if (mousePosition.y > 0.20f * Screen.height)
                {
                    PlayerMenus.GetMenuWithName ("SleepytimeVillageInventory").TurnOff ();
                    actionListToRun.Interact();
                }
            }
        }
    }
    
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.