- Home /
Question by
miwwes · Sep 28, 2017 at 04:34 PM ·
animationanimatoranimationclipanimationevent
How to get an Animator to call an Animation in script?
Hi,
I'm trying to get my UFO ship to play its Tractor Beam animation. This ship beams down a ray of light at a specific instance in the game by the script. The animation in the scene shows up, but is not under the UFO ship. I think it's because at the specific Instance I want to call the animation, it's already at the location I specified? Any help?
public class Movement : MonoBehaviour { public float moveSpeed; private bool moveRight = true; private bool origin = false; public Animation anim; void Start() { moveSpeed = 3f; //anim = GetComponent (); }
void Update()
{
if (moveRight == true) {
transform.position += new Vector3 (0.001f * moveSpeed, 0, 0);
if ((transform.position.x) >= 0.2f) {
moveRight = false;
anim.Play ("Tractor Beam");
}
}
else
{
transform.position -= new Vector3(0.0001f*moveSpeed, 0, 0);
if ((transform.position.x) <= -0.022f)
{
moveRight = true;
}
}
}
}
screen-shot-2017-09-28-at-122816-pm.png
(254.9 kB)
screen-shot-2017-09-28-at-122855-pm.png
(161.2 kB)
Comment