I currently have a problem where an animation will be play one frame at a time if the condition is true, how would I make it play the whole animation if the condition is true.
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.IO.Pipes;
public class animController : MonoBehaviour
{
// private Thread t;
private Animator anim;
private byte[] buffer;
// value received from pipe server
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "ICEClassifier", PipeDirection.InOut);
// Use this for initialization
// only called once
void Start()
{
pipeClient.Connect();
pipeClient.Flush();
}
// called once
//Awake is called after all objects are initialized
void Awake()
{
anim = GetComponent<Animator>();
buffer = new byte[80];
}
//Update is called every frame
// infinite loop
void Update()
{
//Debug.Log(anim.GetTime());
pipeClient.Read(buffer, 0, buffer.Length);
Debug.Log(buffer[0]);
if (buffer[0] == 4)
{
anim.SetBool("point", true);
}
}
}
Then input comes from a pipeServer and its send to this script.
The question comes down to that Animator window and transitions between animations. I guess what you want to have is transition’s “Has Exit Time” set to true. http://docs.unity3d.com/Manual/class-Transition.html
I could also suggest anim.SetTrigger() instead of SetBool(). It’s a different kind of parameter that will automatically sets itself false when it runs once.
Thanks for the reply, I thought this would work but for some reason it did not. The logic of the program is more like this
// inside the update()
// condition check an input from user
if (condition is true)
{
anim.SetTrigger(“point”);
// then play only one frame of the animation
}
// loop again and check to see if condition is true
// if true then play the second frame of the total frames
// then this continues on and on