Hi Wesley,
Thanks for the response. I switched the script around. Now I’m using click gesture to spin the objects and they all spin at the collection level.
My voice commands do not work at the collection level. Only at the mesh level. Basically, same problem as before. This demonstrates it’s not an issue with ray-casting inside or outside the scope as you posted.
I can still only activate voice command on the mesh. I’m confused.
Here’s the script… any ideas
using UnityEngine;
public class DiamondCommands : MonoBehaviour
{
//spin
bool spinObject = false;
bool moveObject = false;
AudioSource audioSource = null;
AudioClip tapSound = null;
void Start()
{
// Add an AudioSource component and set up some defaults
audioSource = gameObject.AddComponent();
audioSource.playOnAwake = false;
audioSource.spatialize = true;
audioSource.spatialBlend = 1.0f;
audioSource.dopplerLevel = 0.0f;
audioSource.rolloffMode = AudioRolloffMode.Custom;
// Load the Sphere sounds from the Resources folder
tapSound = Resources.Load(“Impact”);
}
// Called by GazeGestureManager when the user performs a Select gesture
void OnSelect()
{
// On each Select gesture, toggle whether the user is in placing mode.
spinObject = !spinObject;
audioSource.clip = tapSound;
audioSource.Play();
}
// Called by SpeechManager when the user says the “Move Diamond” command
void Move()
{
moveObject = true;
SpatialMapping.Instance.DrawVisualMeshes = true;
audioSource.clip = tapSound;
audioSource.Play();
}
// Called by SpeechManager when the user says the “Place Diamond” command
void Place()
{
moveObject = false;
SpatialMapping.Instance.DrawVisualMeshes = false;
audioSource.clip = tapSound;
audioSource.Play();
}
// Update is called once per frame
void Update()
{
// Do a raycast into the world that will only hit the Spatial Mapping mesh.
var headPosition = Camera.main.transform.position;
var gazeDirection = Camera.main.transform.forward;
RaycastHit hitInfo;
if (moveObject)
{
if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30.0f, SpatialMapping.PhysicsRaycastMask))
// Move this object’s parent object to
// where the raycast hit the Spatial Mapping mesh.
this.transform.parent.position = hitInfo.point;
// Rotate this object’s parent object to face the user.
Quaternion toQuat = Camera.main.transform.localRotation;
toQuat.x = 0;
toQuat.z = 0;
this.transform.parent.rotation = toQuat;
}
if (spinObject)
{
if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
// Rotate Object
this.transform.parent.Rotate(Vector3.up, Time.deltaTime * 50);
}
}
}