First, sorry for my lack of programming skills. I am a designer, and I just really want to make this one simple app work properly.
I have an object that has an animation. I also have two GUI buttons. I want the animation to play forward when I press the first button, and backwards when I press the other button. (There would be perfect if either the button changes texture for reverse and forward animation, or if it is not possible to press the forward button when that animation has played already
So I have the javascript as this for the first button:
var kniv : AnimationClip;
var metaldel : AnimationClip;
function OnMouseDown () {
GameObject.Find(“kniv”).animation.Play(“kniv”);
GameObject.Find(“metaldel”).animation.Play(“diss2”);
}
First off try making try making simple gui if statements. Your code doesn’t use any guis so right off the bat you can see that your code isn’t going to use those fancy shmancy buttons you’ve made.
Ok. I have tried a solution that worked half way. Im sure this can be done really simple, but this worked 50% at least.
var Box001 : AnimationClip;
var metaldel : AnimationClip;
var cubeRenderer : Renderer;
function OnMouseDown () {
if(cubeRenderer.material.color == Color.red)
cubeRenderer.material.color = Color.white;
else
GameObject.Find("Box001").animation.Play("kniv-sammen");
GameObject.Find("metaldel").animation.Play("diss2");
cubeRenderer.material.color = Color.red;
}
So when pushing the GUI texture this script is attached to it plays the animation if the color of the cube is white. When the color of the cube is red, it plays the last of the two animations “diss2” but not “kniv-sammen” I would like it to not play any of them if the color of the cube is red. Why is it playing one of the animations but not the other?