Emotions bar in 2d visual novel

Announcements, support questions, and discussion for Love/Hate.
Post Reply
Ares_s0ul
Posts: 1
Joined: Mon Jan 23, 2023 11:49 am

Emotions bar in 2d visual novel

Post by Ares_s0ul »

Hello!

I'm making a 2d visual novel and I'm using the adventure creator plugin and lohe/hate. I have created a Faction Database and I have created several factions which in this case would be each character. The idea is that when you choose an option in the conversation the character can decrease or increase happiness, pleasure, arousal or dominance within the Pad.

I have already done this with the modify pad and the check pad in the flowchart. Now I want to make a bar in which every time an option is chosen and a variable of the Pad decreases or decreases, the bar decreases or increases for each variable of the pad.

I talked to the developer of the adventure creator plugin and he told me that to do it I first need the code where this pad of each character is located and thus join it with the adventure creator plugin. What is the code that changes these pad variables?

I accept suggestions

Thanks!
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: Emotions bar in 2d visual novel

Post by Tony Li »

Hi,

There are two ways your custom script can be notified when a Faction Member's PAD values change:

1. Add a Faction Member Events component to the Faction Member GameObject, and connect your script method to the OnModifyPad() UnityEvent, or

2. Add a script that implements the C# interface IModifyPadDeedEventHandler to the Faction Member GameObject. This might look something like:

Code: Select all

using UnityEngine;
using UnityEngine.UI;
using PixelCrushers.LoveHate;

[RequireComponent(typeof(FactionMember))]
public class PadBars : MonoBehaviour, IModifyPadDeedEventHandler
{
    public Slider happiness;
    public Slider pleasure;
    public Slider arousal;
    public Slider dominance;
    
    private FactionMember factionMember;
    
    private void Awake() { factionMember = GetComponent<FactionMember>(); }
    
    public void OnModifyPad(float happinessChange, float pleasureChange, float arousalChange, float dominanceChange)
    {
        happiness.value = factionMember.pad.happiness;
        pleasure.value = factionMember.pad.pleasure;
        arousal.value = factionMember.pad.arousal;
        dominance.value = factionMember.pad.dominance;
    }
}
(Note: I just typed that into the reply; it might have typos.)
Post Reply