Hi guys my animation is not triggering when i press my gui button no errors appear so i asume its finding the anims but it just does not trigger?
relevant part of code below
[/code]
var musicdoor : GameObject;
var button1turnoff : GameObject;
var button2turnoff : GameObject;
public var highlightTexture : Texture2D;
private var originalTexture : Texture2D;
public function OnMouseEnter () : void
{
originalTexture = GetComponent (typeof (GUITexture)).texture;
GetComponent (typeof (GUITexture)).texture = highlightTexture;
}
public function OnMouseExit () : void
{
GetComponent (typeof (GUITexture)).texture = originalTexture;
}
function OnMouseDown () //: void
{
//musicdoor.animation.wrapMode = WrapMode.Clamp;
GetComponent (typeof (GUITexture)).texture = originalTexture;
audio.Play();
musicdoor.animation.wrapMode = WrapMode.Clamp;
musicdoor.animation.CrossFade(“doorcode”,0.5);button1turnoff.layer = 2;//thesearethegameobjectand its hitraycastlayer
button2turnoff.layer = 2;
return;
}
try calling
musicdoor.animation.Play();
In your OnMouseUp() function or down.
Edit: Oops sorry didnt see the CrossFade call. Is the string name for the animation correct (“doorcode”)?
string seems to be fine is there something wrong with the way im calling the variable?
also created a test anim and a new function in unity to check whether it was something to do with the imported object or the mousedown code i created but even with the new script its not working any ideas
no errors flag up so i asumeing its finding the Gameobject and its animation but its just not playing it
var musicdoor : GameObject ;
function Update () {
if (Input.GetKey("z"))
musicdoor.animation.CrossFade("New Animation 1", 0.5);
}
not sure what the issue was but after renameing the object and then reassighning it. got it to work not sure why? if it was a Syntax im asumeing it would of flagged a error message !! might be a syntax! or perhaps the Unity elves!! either one Im happy
cheers Marc for your input
If you have another animation regularly playing, it’ll override the crossfade.
Is the crossfade the only animation call going at the time? (I.E. Do you have any animations being called in Update)