- Home /
help calling obj from seperate obj
here is the first code
class Previewanimation:MonoBehavior
{
string origionalAnimation;
WrapMode wrapMode;
void Awake()
{
//disable script
enabled = false;
}
public void PreviewAnimation(string origionalAnimation, string animation)
{
//enable script
enabled = true;
//Save Animation Settings
this.origionalAnimation = origionalAnimation;
wrapMode = this.animation.wrapMode;
//Play animation once
this.animation.wrapMode = WrapMode.Once;
this.animation.Play(animation);
}
void Update()
{
if(!animation.isPlaying)
{
//Restore Animation Settings
animation.wrapMode = wrapMode;
animation.Play(origionalAnimation);
//disable script
enabled = false;
}
}
}
and i have this set up on the button i made
using UnityEngine; using System.Collections;
public class stardust_atk : MonoBehaviour { void Update() { if(!animation.isPlaying) { Previewanimation("stardust_waiting", "stardust_attack"); } } }
will appreciate all help possible
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613123426im_/https://answers.unity.com/themes/thub/images/avi.jpg)