Skip to Content
Augmented Reality for Developers
book

Augmented Reality for Developers

by Jonathan Linowes, Krystian Babilinski
October 2017
Intermediate to advanced
548 pages
13h 23m
English
Packt Publishing
Content preview from Augmented Reality for Developers

Bounce sound effect

Before moving on, let's add a sound effect when the ball bounces. If you've installed the BallGameArt assets, there's a sound effects folder with a sound named bounce. We'll play the clip when the ball collides with anything. Let's script it now and we'll explain colliders more when we add the GoalCollider later.

In your Project Assets/ARPlayBall/Scripts folder create a new C# script named PlaySoundOnHit and open it for editing:

File: PlaySoundOnHit.csusing UnityEngine; [RequireComponent(typeof(AudioSource))] public class PlaySoundOnHit : MonoBehaviour { public AudioClip clip; private AudioSource source; void Start() { source = GetComponent<AudioSource>(); source.spatialBlend = 1.0f; source.playOnAwake = false; source.clip ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Augmented Reality Game Development

Augmented Reality Game Development

Micheal Lanham
Augmented Reality

Augmented Reality

Joseph Rampolla, Greg Kipper

Publisher Resources

ISBN: 9781787286436Supplemental Content