Page 1 of 1
Adjust Impact when reporting deed
Posted: Fri Oct 09, 2020 3:04 am
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
Re: Adjust Impact when reporting deed
Posted: Fri Oct 09, 2020 9:11 am
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.