public abstract int InitSpatializer(string modelPath)
Parameter | Type | Description |
modelPath | string | The absolute path of the 3D sound effect resource file |
modelPath
empty.StreamingAssets
directory of the project and copy it to the corresponding directory of different platforms based on the content of the copyFileFromAssetsToPersistent function in SampleCode
.SampleCode
.public abstract int EnableSpatializer(bool enable, bool applyToTeam)
Parameter | Type | Description |
enable | bool | You can hear the 3D sound effect after enabling it. |
applyToTeam | bool | This parameter specifies whether 3D sound effect is enabled within the team and takes effect only when enable is true . |
public abstract bool IsEnableSpatializer()
Returned Value | Description |
true | Enabled |
false | Disabled |
100
.Distance (Unit in the Engine) | Attenuation Coefficient |
0 < N < range/10 | 1.0 (no attenuation) |
N ≥ range/10 | Range/10/N |
public abstract void UpdateAudioRecvRange(int range)
Parameter | Type | Description |
range | int | The range within which the sound effect can be heard in distance unit used by the game engine. We recommend that you set it to 100 . |
public abstract int UpdateSelfPosition(int position[3], float axisForward[3], float axisRight[3], float axisUp[3])
Parameter | Type | Description |
position | int[] | Local position (forward, right, and up) in the world coordinate system |
axisForward | float[] | Forward vector in the local coordinate system |
axisRight | float[] | Right vector in the local coordinate system |
axisUp | float[] | Up vector in the local coordinate system |
FVector cameraLocation = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0)->GetCameraLocation();FRotator cameraRotation = UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0)->GetCameraRotation();int position[] = { (int)cameraLocation.X,(int)cameraLocation.Y, (int)cameraLocation.Z };FMatrix matrix = ((FRotationMatrix)cameraRotation);float forward[] = { matrix.GetColumn(0).X,matrix.GetColumn(1).X,matrix.GetColumn(2).X };float right[] = { matrix.GetColumn(0).Y,matrix.GetColumn(1).Y,matrix.GetColumn(2).Y };float up[] = { matrix.GetColumn(0).Z,matrix.GetColumn(1).Z,matrix.GetColumn(2).Z};ITMGContextGetInstance()->GetRoom()->UpdateSelfPosition(position, forward, right, up);
Transform selftrans = currentPlayer.gameObject.transform;Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, selftrans.rotation, Vector3.one);int[] position = new int[3] { selftrans.position.z, selftrans.position.x, selftrans.position.y };float[] axisForward = new float[3] { matrix.m22, matrix.m02, matrix.m12 };float[] axisRight = new float[3] { matrix.m20, matrix.m00, matrix.m10 };float[] axisUp = new float[3] { matrix.m21, matrix.m01, matrix.m11 };ITMGContext.GetInstance().GetRoom().UpdateSelfPosition(position, axisForward, axisRight, axisUp);
UpdateSelfPosition
function to update the position information and send it to other users over the network. UpdateOtherPosition
can also pass in the position information of other players locally without using the network, making it suitable for VR game scenarios.UpdateOtherPosition
, remote coordinates will be discarded, which will affect the next room entry. Therefore, to update the player coordinates locally, update the coordinates of all players.public abstract int UpdateOtherPosition(int position[3])
Parameter | Type | Description |
position | int[] | Position of another player (forward, right, and up) in the world coordinate system |
openid
will no longer have the 3D sound effect.virtual int AddSpatializerBlacklist(const char* openId);
openid
from the blocklist, you need to call the following API:virtual int RemoveSpatializerBlacklist(const char* openId);
virtual int ClearSpatializerBlacklist();
InitSpatializer
is 0
.UpdateAudioRecvRange
is too small.UpdateSelfPosition
API is called periodically.
Was this page helpful?