- Home /
Problem with new version (Unity > Animation)
Using Unity Pro
Okay so, I'm working on this
There is blink mechanics. If you blink, your sanity will reduce by 10. You can blink by click screen but you must wait for 10 seconds for next turn.
BlinkClick script
#pragma strict
var topLid : GameObject;
var bottomLid : GameObject;
var regenSanity : float = 10.0;
private var canClick : boolean = true;
var timer : float = 3.0;
private var sanityScript : InsanityManager;
function Start()
{
sanityScript = GameObject.Find("First Person Controller").GetComponent(InsanityManager);
topLid = GameObject.Find("Upper_Eyes");
bottomLid = GameObject.Find("Down_Eyes");
}
function Update()
{
if (canClick)
{
if (Input.GetMouseButtonDown(0))
{
timer = 10.0;
canClick = false;
topLid.animation.Play("UpperLid");
bottomLid.animation.Play("DownLid");
sanityScript.currentSanity -= regenSanity;
}
}
else
{
timer -= Time.deltaTime;
if (timer <= 0)
{
canClick = true;
}
}
}
I have 2 GameObject, "Upper_Eyes" and "Down_Eyes". Each of them has animation called "UpperLid" and "DownLid" I attach this gameobject to the script(Inspector)
What the problem is the script is trying to access the animation but script don't find any animations on it. This is the error I got.
ERROR#1
The AnimationClip 'UpperLid' used by the Animation component 'Upper_Eyes' must be marked as Legacy. UnityEngine.Animation:Play(String) BlinkClick:Update() (at Assets/Scripts/SanityScripts/SanityScripts/BlinkClick.js:28)
ERROR#2
The animation state UpperLid could not be played because it couldn't be found! Please attach an animation clip with the name 'UpperLid' or call this function only for existing animations. UnityEngine.Animation:Play(String) BlinkClick:Update() (at Assets/Scripts/SanityScripts/SanityScripts/BlinkClick.js:28)
ERROR#3
The AnimationClip 'DownLid' used by the Animation component 'Down_Eyes' must be marked as Legacy. UnityEngine.Animation:Play(String) BlinkClick:Update() (at Assets/Scripts/SanityScripts/SanityScripts/BlinkClick.js:29)
ERROR#4
The animation state DownLid could not be played because it couldn't be found! Please attach an animation clip with the name 'DownLid' or call this function only for existing animations. UnityEngine.Animation:Play(String) BlinkClick:Update() (at Assets/Scripts/SanityScripts/SanityScripts/BlinkClick.js:29)
already attached the animation to it!*
do know what I need to do. I need to set this animation to Legacy, but the problem is that there is no option of it!*
If you guys need 2 more script that involved in this mechanics. Here it is
Dizzy script
#pragma strict
private var mBlur : MotionBlur;
private var sanityScript : InsanityManager;
function Start()
{
mBlur = GameObject.Find("Main Camera").GetComponent(MotionBlur);
sanityScript = GameObject.Find("First Person Controller").GetComponent(InsanityManager);
mBlur.enabled = false;
}
function Update()
{
if(sanityScript.currentSanity >= 20)
{
mBlur.enabled = true;
mBlur.blurAmount = 0.2f;
}
if(sanityScript.currentSanity >= 40)
{
mBlur.enabled = true;
mBlur.blurAmount = 0.4f;
}
if(sanityScript.currentSanity >= 60)
{
mBlur.enabled = true;
mBlur.blurAmount = 0.6f;
}
if(sanityScript.currentSanity >= 80)
{
mBlur.enabled = true;
mBlur.blurAmount = 0.85f;
}
if(sanityScript.currentSanity >= 90)
{
mBlur.enabled = true;
mBlur.blurAmount = 0.99f;
}
}
InsanityManager
#pragma strict
var currentSanity : float = 20.0;
var maxSanity : float = 100.0;
var minSanity : float = 0.0;
var barLength = 0.0;
function Start()
{
barLength = Screen.width / 8;
}
function Update()
{
if(currentSanity <= 100)
{
currentSanity -= Time.deltaTime;
}
if(currentSanity >= 100)
{
currentSanity = maxSanity;
}
if(currentSanity <= 0)
{
currentSanity = minSanity;
}
}
function OnGUI()
{
GUI.Box(new Rect(5, 70, 70, 20), "Sanity");
GUI.Box(Rect(70, 70, barLength, 20), currentSanity.ToString("0") + "/" + maxSanity);
}