Forum rules - please read before posting.

2D Closeup sprite

edited March 2022 in Technical Q&A

Hey everyone

I am trying to make a hotspot interaction where once the player clicks on the object an enlarged picture of said object shows ontop of the pre-existing enviroment with a description of the item underneath.

I have two questions
1) For some reason the source image keeps refreshing and it goes back to being a white rectangle, despite it still being linked in Unity UI.

2) My game does not involve a player but rather the camera moves along with the cursor. The result I'm going for is for the player to click on a hotspot -> Camera freezes and stops at the coordinates where the player last clicked on the hotspot -> Custom menu shows up.

I dont know how to achive the 'pause during gameplay' effect while still having my menu run on hotspot interaction.

Thank you in advance

https://ibb.co/FV6sZHx
https://ibb.co/0ttt7WN
https://ibb.co/S0LZLRC
https://ibb.co/s63D7xD

Comments

  • Welcome to the community, @Mkay.

    For some reason the source image keeps refreshing and it goes back to being a white rectangle, despite it still being linked in Unity UI.

    If you link a Unity UI Image component to an AC Graphic element, then AC will set the Image's sprite according to the element's Graphic type property.

    Your screenshots show this is currently set to Document Texture, which mean it'll set itself to the texture of the active Document. If there is no Document currently active, or that Document has no texture assigned, then the Graphic element will assign a "null" texture resulting in a large white rectangle.

    If you want the Image's sprite to remain constant, you don't actually need to link it to the Menu Manager - this is only necessary if you need AC to be able to control it.

    If you want to change the Image's sprite dynamically, you can do this either through animation, or through script. The animation method would involve un-linking the Image component from the Menu, and creating different animations for it that set the sprite to different values. Changing the sprite would then be a case of using the Object: Animate Action, as you turn on the Menu, to update which animation is played and therefore which sprite is shown.

    The scripting method would involve keeping the Image component linked to the Menu, and then updating the assigned sprite by accessing the Graphic element's uiImage property:

    (AC.PlayerMenus.GetElementWithName ("Environment Hotspot", "Robert Box Image") as MenuGraphic).uiImage.sprite = myNewSprite;
    

    I dont know how to achive the 'pause during gameplay' effect while still having my menu run on hotspot interaction.

    Can you elaborate on what you're referring to with "pause during gameplay"? Is this the Menu, or an ActionList you're running?

    I would note though that your Menu's Appear type is currently set to During Gameplay, which means it will show at all times during gameplay (unless locked) and hide automatically during cutscenes.

    If you want full control over when it shows - both during gameplay and cutscenes - you can instead set this to Manual, and use the Menu: Change state Action to turn in on and off manually.

    Alternatively, if your camera movement is being handled through an ActionList, and you want it to run without blocking gameplay, you can set the ActionList's When running property to Run In Background.

  • Hey Chris
    Thanks for the fast reply!

    The image's sprite now works perfectly as I was not aware that I didn't need an element in the menu for it if I'm using Unity UI, so thanks a bunch!

    As for my Menu showing up, I am aware that I have it set to During Gameplay, I am using the hotspot's ActionList editor to Lock and Unlock it.

    I originally tried setting it to Manual but for some reason, the menu does not show up when clicking on the Hotspot.

    My main concern at the moment is having the camera movement stop the moment the player clicks on the hotspot (in the same coordinates). Kind of similar to when we activate the default Pause menu that comes with AC.

    If I am understanding correctly that means that I need to have the 'Pause game when enabled' checked, however since Manual doesn't work I cannot do that.

    I have no ActionLists for any cameras at the moment since I'm a bit confused about how to approach this in the first place.

    Here is a screenshot of my menu settings once more, one set to During gameplay the other set to Manual:

    https://ibb.co/Pxxp5hR
    https://ibb.co/4TnnmHT

    Thanks in advance

  • I have no ActionLists for any cameras at the moment since I'm a bit confused about how to approach this in the first place.

    How is it that your camera is moving at this moment? You mention it moving with the cursor - is this via a custom script, or the "Cursor influence" panel in the active GameCamera? Share any relevant screenshots you can.

    To freeze the camera's motion, you'll either need to rely on a custom script (depending on the above), or have the Menu pause the game as you've mentioned.

    Setting the Appear type to Manual, checking Pause game when enabled?, and unchecking Enabled on start? in your Menu's properties should then allow you to use the Menu: Change state Action to turn on the Menu as part of a Hotspot interaction.

    If your Menu doesn't show when following these steps, check your Console window and share images of your ActionList and updated Menu's properties.

    I'm attempting to recreate this issue by running a Hotspot interaction that contains a Menu: Change state Action to turn on the default interface's "Options" menu - which is also set to "Manual" - but on my end this causes it to turn on.

  • Hey,

    My game camera's 'Target object to control movement' is set to a game object that has this script attached to it which allows the camera to move along with the cursor :

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class FollowCursor : MonoBehaviour
    {
    
        private void Update ()
        {
            Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
            mouseWorldPosition.z = 0f;
            transform.position = mouseWorldPosition;
        }
    
    }
    

    https://ibb.co/HXHkFpr

    I followed the steps you mentioned while setting the Menu's Appear type to **Manual **and still no luck with the menu showing up upon clicking on the hotspot.

    The console says that 'Menu is locked' however I have an ActionList editor set as a use interaction for the hotspot that is supposed to Unlock the menu:

    https://ibb.co/JjSvD5Y

    I also tried the 'Turn on menu'/'Turn off menu' instead of locking to see if that would fix the issue but it still doen't work. Here are screenshots of my ActionList Editors :

    1) Hotspot Use Interaction :

    https://ibb.co/x86QcSv

    2) Menu Back Button:

    https://ibb.co/XSjxDg2

  • Both of your ActionLists show the "Lock Menu" command being used, so running them won't result in the Menu turning on.

    If the Console is reporting that the Menu is locked, you could insert beforehand an additional Menu: Change state Action with the "Unlock Menu" command to ensure it's unlocked.

    However, it's not normally necessary to lock a "Manual" Menu in the first place, since it's display is controlled through Actions anyway.

    If you've got an errant Menu: Change state Action somewhere that's locking the Menu unexpectedly, you can use the Actions Manager to search your project for instances of this Action type.

  • Hey Chris,

    I must've attached the wrong screenshot of both menus being locked, my bad.

    I honestly don't know what I did this time but I tried having the **Menu: Change state ** action to Turn off/on again, and this time it worked!

    Thanks a lot for your time! :)

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.