I’ve got a test App with which I’m trying to get an object to travel around a waypoint route on a verbal start command, “Start Sequence Three”. The waypoint script works fine if I just let it startup without a verbal command . I even have a verbal command to change the color of the object (capsule) that moves around the waypoints that works as well if I just start the script up by running the scene (shows that verbal command scripting is working) The waypoint script has to be place within Update (). When I try to insert the verbal command to start the Update process, I get a compiler error like "Local function ‘Update’ is called but never used’. The script and Scene screen shot are shown below. NOTE: The only error flagged by the red squiggle is under the word Update in the statement “void Update ()”. Associated with it is the error message above.
QUESTION: What am I doing wrong? All help is appreciated. I’m not a programmer and new to Unity.
Cheers,
Bob G.
SCRIPT:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.Speech;
public class MoveOpponent01B : MonoBehaviour
{
private KeywordRecognizer keywordRecognizer;
private Dictionary<string, Action> actions = new Dictionary<string, Action>();
public GameObject waypoints;
int current = 0;
float rotSpeed;
public float speed;
float WPradius = .1f;
public Renderer rend;
void Start()
{
actions.Add("start sequence three", StartThree);
actions.Add("red", Red);
Debug.Log("StartTT");
keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
keywordRecognizer.OnPhraseRecognized += RecognizedSpeech;
keywordRecognizer.Start();
rend = GetComponent<Renderer>();
}
private void RecognizedSpeech(PhraseRecognizedEventArgs speech)
{
Debug.Log(speech.text);
actions[speech.text].Invoke();
}
// private void StartThree()
private void Red()
{
rend.material.color = Color.red;
}
private void StartThree() {
void Update() {
{
Debug.Log("StartThree");
if (Vector4.Distance(waypoints[current].transform.position, transform.position) < WPradius)
{
current++;
if (current >= waypoints.Length)
{
current = 0;
}
}
transform.position = Vector4.MoveTowards(transform.position, waypoints[current].transform.position, Time.deltaTime * speed);
}
}
}
}