I am a novice to C#
PICS
CODE
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.UI;
using HDProDesignCarEngineSoundFusion;
using FMOD;
using FMODUnity;
public class EngineSoundMapper : MonoBehaviour
{
[Header("CarSFX")]
FMOD.Studio.PARAMETER_ID RPMID;
FMOD.Studio.PARAMETER_ID LoadID;
FMOD.Studio.PARAMETER_ID TurboID;
FMOD.Studio.PARAMETER_ID TurboBlowOffID;
FMOD.Studio.PARAMETER_ID BackFireID;
FMOD.Studio.PARAMETER_ID Boost;
[SerializeField] StudioEventEmitter Engine_01_RPM;
public FMOD.Studio.EventInstance instance;
[SerializeField]
//FMODUnity.EventReference Engine_01_RPM;
[Range(0f, 10000f)]
public float carrpm;
public bool cargas;
public float HDenginegas;
public float HDengineLoad;
public float HPvalue;
public SoundCombiner sound;
public race_hud Race;
public GameObject Car;
public GameObject bot;
// Start is called before the first frame update
public void Start()
{
sound = gameObject.GetComponent<SoundCombiner>();
Race = FindObjectOfType<race_hud>();
Car = Race.car;
HPvalue = Car.GetComponent<car>().HP;
carrpm = Race.rpm;
FMOD.Studio.PARAMETER_DESCRIPTION paramDescription;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("RPM", out paramDescription);
RPMID = paramDescription.id;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("Load", out paramDescription);
LoadID = paramDescription.id;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("Turbo", out paramDescription);
TurboID = paramDescription.id;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("TurboBlowOff", out paramDescription);
TurboBlowOffID = paramDescription.id;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("BackFire", out paramDescription);
BackFireID = paramDescription.id;
Engine_01_RPM.EventDescription.getParameterDescriptionByName("Boost", out paramDescription);
Boost = paramDescription.id;
Engine_01_RPM.SetParameter(RPMID, Race.rpm);
Engine_01_RPM.SetParameter(LoadID, 1);
}
public void Update()
{
//Base engine sounds
Engine_01_RPM.SetParameter(RPMID, carrpm);
Engine_01_RPM.SetParameter(LoadID, HPvalue);
}
////Additional turbo sound
//void UpdateTurbo()
//{
// EngineEmitter.SetParameter(TurboID, Car.);
// if (Car.CurrentTurbo > 0.2f && (Car.CurrentAcceleration < 0.2f || Car.InChangeGear) && ((Time.realtimeSinceStartup - LastBlowOffTime) > MinTimeBetweenBlowOffSounds))
// {
// EngineEmitter.SetParameter(TurboBlowOffID, 0);
// EngineEmitter.SetParameter(TurboBlowOffID, Car.CurrentTurbo);
// LastBlowOffTime = Time.realtimeSinceStartup;
// }
//}
////Additional boost sound
//void UpdateBoost()
//{
// EngineEmitter.SetParameter(Boost, Car.InBoost ? 1 : 0);
//}
//void OnBackFire()
//{
// EngineEmitter.SetParameter(BackFireID, Random.Range(0.1f, 1f));
// EngineEmitter.SetParameter(BackFireID, 0);
}