How To Play an Audio file in JavaScript

Here is a quick and simple way to play an audio clip in JavaScript

const audio = new Audio('path/to/audio.mp3')
audio.play()

That is literally it.

You can set “audio.play()” to where ever you need in your code so it gets triggered when needed.

https://stackoverflow.com/questions/9419263/how-to-play-audio

Unity Fails to Build iOS Game due to “LocationService” being used

Ran into an interesting problem while trying to compile a Unity project for iOS. It failed to build because

“LocationService class is used but Locations Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)”

LocationService class is used but Locations Usage Description is empty

Well as far as I know there is not anything calling or requesting location services. I probably could have just put a reason for requesting the service under the build options in Project Settings. But why “use” something we don’t need?

Using the handy grep tool from a terminal, I was able to search through the project for “LocationService” and that returned a couple hits for files in the PlayMaker folder.

Looks like PlayMaker has a couple preconfigured “scripts” for Starting, Stopping, and Requesting Location.

Deleting the following four C# files resolved the error and it built fine afterwards.

GetLocationInfo
StopLocationServiceUpdates
StartLocationServiceUpdates
ProjectLocationToMap

You can find these files in your project under Assets > PlayMaker > Actions > Device

Unity Game Scene tab flickers during game play

There appears to be an issue with HDPI displays and the Unity Game tab while testing the game in unity. Have had issues where the UI elements will resize and not work correctly. Issue seems to be with how Windows scales the screen.

Dropping the scaling to 100% and/or the resolution down to 1920×1080 seems to resolve the issue.

Unity not loading scene levels

Problem: Game would finish level, but would not load next one.

The issue was that all the levels were not included in the build scene, (File -> Build Settings -> Scenes In Build) so even though the level was correct in PlayMaker, it would not load the level in the Game window while testing.

To add scene to build, open the scene up in the editor, then open the Build Settings from File -> Build Settings… or Ctrl+Shift+B and Add Open Scenes

Unity 3D – Changing color on game object changes color on other objects in scene

Problem: When changing the shader color on a game object, the color on other game objects changes.

Reason: This happens because the other game objects are using the same Mesh Renderer as the game object your modifying.  So when your changing the shader, your actually modifying the Mesh Renderer, not the game object.

Fix: Change the Mesh Renderer for the game object.

In the example picture below, when you change the color on the cube (highlighted red) the color on the capsule changes, because they both are using the same Mesh Renderer (highlighted green).  To fix, change either the Cube or Capsule to a different Mesh Renderer (highlighted green)