Forum rules - please read before posting.

Regarding portraits

Hello Chris,
Hope you are well.
We want to achieve a lighting effect on the portraits. Probably they are UI related, so maybe adding a light somewhere can achieve that on the portrait. Is it possible? Not sure what's the sorting layer or where can I do that...
Basically the want to play a bit with the lighting based on where the character is, when talking to "movable" NPCs or even the main character.

On another note: is it possible flip the picture inside the portrait? The problem is not about creating a second protrait based on the left/right position, but actually avoiding to add "another picture but flipped" for the same character. Not sure if I'm clear. Let me know.

Thanks a lot!

Comments

  • If you make use of Unity UI for your menu, then you can apply a custom shader to your portrait Image component. This won't specifically involve AC, though you may want to make use of e.g. the OnMenuTurnOn custom event to update the shader based on which character is speaking - see this tutorial for more on events.

    This technique can also be used to update the portrait Image's RectTransform to flip the scale. For example:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class FlipPortrait : MonoBehaviour
    {
    
        public Canvas canvas;
        public Image portraitImage;
    
        private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            if (menu.RuntimeCanvas == null || menu.RuntimeCanvas != canvas || menu.speech == null) return;
    
            Char speaker = menu.speech.GetSpeakingCharacter ();
            if (speaker != null && speaker.gameObject.name == "MyNPC")
            {
                portraitImage.rectTransform.localScale = new Vector3 (-1f, 1f, 1f);
            }
            else
            {
                portraitImage.rectTransform.localScale = new Vector3 (1f, 1f, 1f);
            }
        }
    
    }
    
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.