- Home /
"Namespace Error" when there shouldn't be
Hi, I am new to Unity and C#. I have been working on this virtual reality game project for a while now (Oculus Quest) and I would like to get it to work. Since I switched to the Android platform I have been running into some namespace errors when I press "Build". Keep in mind that my code has worked perfectly before when clicking 'Play' both on Android and not. It is just errors when I press 'Build'.
i
Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.Speech;
public class CommandBook : MonoBehaviour
{
private Dictionary<string, Action> keywordActions = new Dictionary<string, Action>();
private KeywordRecognizer keyword;
private void Start()
{
keywordActions.Add("Hold", Levitate);
keywordActions.Add("Thrusters Enguaged", Thrusters);
keywordActions.Add("Fire", Cannon);
keywordActions.Add("Lockdown", Spirit);
keyword = new KeywordRecognizer(keywordActions.Keys.ToArray());
keyword.OnPhraseRecognized += OnKeywordsRecognized;
keyword.Start();
}
private void OnKeywordsRecognized(PhraseRecognizedEventArgs args)
{
//Debug.Log("Keyword: " + args.text);
keywordActions[args.text].Invoke();
}
public CommandActivation commands;
public void Levitate()
{
print("Hovering");
}
//Launches a projectile
public void Thrusters()
{
print("Thrusters Enguaged");
}
public void Cannon()
{
commands.cannonball();
print("Cannon Fired");
}
public void Spirit()
{
print("Lockdown In Play");
}
}
i
i
Here is my code that is connected to my piece above:
using UnityEngine;
public class CommandActivation : MonoBehaviour
{
//Projectiles if there is any
public Rigidbody CannonProjectile;
public Transform tip;
public void cannonball()
{
Rigidbody cannonproj;
cannonproj = Instantiate(CannonProjectile, tip.position, tip.rotation) as Rigidbody;
cannonproj.velocity = tip.forward * 50;
}
}
i
i
Like I said it works just fine in the editor, but when I press 'Build' or 'Build and Run' it throws these errors at me. This is the core of my game and I have many many ideas orbiting this core mechanic. I had high hopes that this would work, so if anyone could help me I would be very happy.
Thank you
Your answer
