我实现了IBM Watson的“语音转文本”,因此当我说“跳转” /“愤怒”时,我的角色将播放特定的音频剪辑。一切似乎都正常,但是我的角色对我的语音命令没有反应。
我的CharacterController.cs
:
using UnityEngine;
public class CharacterController : MonoBehaviour
{
// Use this for initialization
public Animator anim;
public AudioSource[] _audio;
void Start()
{
}
// Update is called once per frame
void Update()
{
anim = GetComponent<Animator>();
_audio = GetComponents<AudioSource>();
}
public void CharacterActions(string ActionCommands)
{
ActionCommands = ActionCommands.Trim();
switch (ActionCommands)
{
case "jump":
anim.Play("jump", -1, 0f);
_audio[0].Play();
break;
case "anger":
anim.Play("rage", -1, 0f);
_audio[1].Play();
break;
default:
anim.Play("idle", -1, 0f);
break;
}
}
}