private void Deselect() //when the lat object that was selected is NOT hit by the raycast change color back to red { //audioSource = lastObject.GetComponent<AudioSource>(); isSelected = false; if (changeMaterial != null) { changeMaterial.ChangeTo("red"); } audioSource.Stop(); isPlayingCord = false; //myFloat.isFloatingUp = false; //myFloat.isFloatingDown = true; }
private void Select(GameObject hitObject) //when hit by the raycast change color to blue and play a cord { isSelected = true; changeMaterial = hitObject.GetComponent <ChangeMaterial>(); audioSource = hitObject.GetComponent <AudioSource>(); changeMaterial.ChangeTo("blue"); lastObject = hitObject; myFloat.isFloatingUp = true; myFloat.isFloatingDown = false; Instantiate(ringPrefab, new Vector3(hitObject.transform.localPosition.x, hitObject.transform.localPosition.y, hitObject.transform.localPosition.z), Quaternion.identity); isPlayingCord = true; if (isPlayingCord) { if (!audioSource.isPlaying) { audioSource.Play(); } } }