The error is;
" Operator ‘+’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘Object’."
the code in question is;
#pragma strict
var coolTimeMax: float = 8.0f;
var isUseSkill: boolean = false;
var buttonClickTrue: AudioClip;
var buttonClickFalse: AudioClip;
private var timer: float = 1.0f;
private var coolTime: float = 0.0f;
private var silder: UISlider = null;
private var getCam: GameObject;
private var soundRate: float = 0.0; // variable to hold sound rate
private var soundDelay: float = 0.0;
function Start ()
{
silder = GetComponent(UISlider);
getCam = GameObject.FindGameObjectWithTag("MainCamera");
}
function Update ()
{
silder.sliderValue = timer;
if (UICamera.hoveredObject != null && UICamera.hoveredObject.name == ("btn_Farmer") && Input.GetMouseButton(0) && !isUseSkill && timer == 1)
{
PlaySound ( buttonClickTrue, 0 );
getCam.GetComponent(InGameGUI).SetBuildChoice ( gameObject );
}
if (isUseSkill)
{
StartTimer ();
isUseSkill = false;
}
}
function StartTimer ()
{
var t: float = 0.0f;
while (t < 1)
{
t += Time.deltaTime / coolTimeMax;
timer = Mathf.Lerp (0, 1, t);
yield;
}
}
function PlaySound ( soundName, soundDelay ) // calls to play sound based on sound file name attached to object
{
if ( !audio.isPlaying && Time.time > soundRate ) // sets sound rate
{
soundRate = Time.time + soundDelay; // option to add a delay to the sound before it starts playing
audio.clip = soundName;
audio.Play ();
yield WaitForSeconds ( audio.clip.length );
}
}
the exact line this error is pointing too is;
soundRate = Time.time + soundDelay;
This makes no sense! last I soundRate is a float, Time.time is a float, and soundDelay is a float! Where does it get this “Object” type from?!