Avatar voice set to narrate. RPC untested

This commit is contained in:
Abdul Mukheem Shaik 2024-05-26 22:34:50 +02:00
parent 9c8a5f8fb3
commit 8cfc1b16ea
7 changed files with 200 additions and 2 deletions
Assets
SharedSpatialAnchors
ThirdParty/Photon/PhotonUnityNetworking/Resources
ProjectSettings

@ -946,9 +946,11 @@ GameObject:
- component: {fileID: 3196596099490932396}
- component: {fileID: 4067417591161320129}
- component: {fileID: 3569971862085791352}
- component: {fileID: 1553315533}
- component: {fileID: 1553315532}
m_Layer: 0
m_Name: TalkingAvatar
m_TagString: Untagged
m_TagString: Avatar
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -962,7 +964,7 @@ Transform:
m_GameObject: {fileID: 3128949758138181256}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: 1.42, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1.3, z: 1.3}
m_LocalScale: {x: 1.25, y: 1.3, z: 1.3}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5280034911807405635}
@ -1063,6 +1065,116 @@ MonoBehaviour:
m_SynchronizeAngularVelocity: 1
m_TeleportEnabled: 1
m_TeleportIfDistanceGreaterThan: 3
--- !u!82 &1553315533
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3128949758138181256}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: d04b5fce2c9627f4483faa6f2951f454, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &1553315532
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3128949758138181256}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: df56a8fa2ce0307498969d4c550617b5, type: 3}
m_Name:
m_EditorClassIdentifier:
audioNarration_1: {fileID: 8300000, guid: d04b5fce2c9627f4483faa6f2951f454, type: 3}
audioNarration_2: {fileID: 8300000, guid: 9b80a823b03707d42a56551b996ed9be, type: 3}
--- !u!1 &3489539847802727250
GameObject:
m_ObjectHideFlags: 0

@ -52,6 +52,8 @@ public class API : MonoBehaviour
private WebSocketController webSocketControllerScript;
public bool isButtonPressed = false; // Boolean to keep voltage updated as long as the turbine is rotating
PhotonView photonView;
private GameObject avatar;
private AudioController audioControllerScript;
void Start()
@ -79,6 +81,11 @@ public class API : MonoBehaviour
webSocketController = GameObject.FindGameObjectWithTag("WebController");
webSocketControllerScript = webSocketController.GetComponent<WebSocketController>();
StartCoroutine(GetText());
avatar = GameObject.FindGameObjectWithTag("Avatar");
audioControllerScript = avatar.GetComponent<AudioController>();
audioControllerScript.fn_call_AudioNarration2();
}
[PunRPC]

@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class AudioController : MonoBehaviour
{
AudioSource audioSource;
public AudioClip audioNarration_1;
public AudioClip audioNarration_2;
PhotonView photonView;
// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
}
public void Update()
{
}
// Audio Narration 1
public void fn_call_AudioNarration1()
{
photonView = PhotonView.Get(this);
photonView.RPC("RPC_startAudioNarration1", RpcTarget.All);
}
[PunRPC]
public void RPC_startAudioNarration1()
{
StartCoroutine(CoRoutine_startAudioNarration1());
}
IEnumerator CoRoutine_startAudioNarration1()
{
yield return new WaitForSeconds(1.0f);
audioSource.PlayOneShot(audioNarration_1);
}
// Audio Narration 2
public void fn_call_AudioNarration2()
{
photonView = PhotonView.Get(this);
photonView.RPC("RPC_startAudioNarration2", RpcTarget.All);
}
[PunRPC]
public void RPC_startAudioNarration2()
{
StartCoroutine(CoRoutine_startAudioNarration2());
}
IEnumerator CoRoutine_startAudioNarration2()
{
yield return new WaitForSeconds(0.0f);
audioSource.PlayOneShot(audioNarration_2);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df56a8fa2ce0307498969d4c550617b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -386,5 +386,7 @@ public class SharedAnchorControlPanel : MonoBehaviour
var networkedAvatar = PhotonPun.PhotonNetwork.Instantiate(TwinTurbine_talkingAvatar.name, new Vector3(1f, -0.2f, 1.15f), Quaternion.Euler(Vector3.up * 120));
var photonGrabbableAvatar = networkedAvatar.GetComponent<PhotonGrabbableObject>();
}
}

@ -53,6 +53,8 @@ MonoBehaviour:
- RPC_GreenButtonClick
- RPC_VoltageUpdate
- RPC_WT_Turn
- RPC_startAudioNarration1
- RPC_startAudioNarration2
DisableAutoOpenWizard: 1
ShowSettings: 1
DevRegionSetOnce: 1

@ -7,6 +7,7 @@ TagManager:
- WebController
- WindTurbine
- GUIData
- Avatar
layers:
- Default
- TransparentFX