Adjust Impact when reporting deed

Announcements, support questions, and discussion for Love/Hate.
Post Reply
Illustrator
Posts: 4
Joined: Mon Apr 20, 2020 3:58 am

Adjust Impact when reporting deed

Post by Illustrator »

My scenario is this, player can cause different noises with different volumes. I'd like the deed impact change according to the sound volume (or other parameter). Is there a way for this or do I need to setup different deeds for different volumes?

Best regards,
Illustrator
User avatar
Tony Li
Posts: 22089
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adjust Impact when reporting deed

Post by Tony Li »

Hi,

You can add a small script to the character that implements the IWitnessDeedEventHandler interface. It just has one method, WitnessDeed(Rumor). Example:

Code: Select all

public class SoundOnDeed : MonoBehaviour, IWitnessDeedEventHandler
{
    public void WitnessDeed(Rumor rumor)
    {
        var audioSource = GetComponent<AudioSource>();
        audioSource.volume = Math.Abs(rumor.impact) / 100; // (Range [-100,+100])
        audioSource.Play();
    }
}
You can check the impact of the Rumor that's passed to it. There's also an equivalent Faction Member Events component with one OnWitnessDeed(Rumor) UnityEvent that you can hook up in the Inspector.
Post Reply