I get both of these errors on line 18 and 26: BCE0026: ‘void’ cannot be used in a boolean context.
#pragma strict
var Fon : String;
var Foff : String;
var Con : String;
var Coff : String;
function Update () {
if(Input.GetKeyDown(KeyCode.Space)){
ForceLight();
}
if(Input.GetKeyDown("c")){
ChargedLight();
}
}
function ForceLight () {
if (animation.CrossFade(Fon)){
animation.CrossFade(Fon);
} else {
animation.CrossFade(Foff);
}
}
function ChargedLight () {
if (animation.CrossFade(Con)){
animation.CrossFade(Con);
} else {
animation.CrossFade(Coff);
}
}
Not sure why you’re asking if an animation is crossfading… That’s the problem though. If you’re wanting to check if the animation exists, check that it’s not null:
#pragma strict
var Fon : String;
var Foff : String;
var Con : String;
var Coff : String;
function Update ()
{
if(Input.GetKeyDown(KeyCode.Space))
{
ForceLight();
}
if(Input.GetKeyDown("c"))
{
ChargedLight();
}
}
function ForceLight ()
{
if (animation[Fon] != null)
{
animation.CrossFade(Fon);
}
else
{
animation.CrossFade(Foff);
}
}
function ChargedLight ()
{
if (animation[Con] != null)
{
animation.CrossFade(Con);
}
else
{
animation.CrossFade(Coff);
}
}