Use Vuforia, Unity to implement AR recognition diagram to trigger audio playback

Source: Internet
Author: User

This article is mainly attributed to the great Gods of the AR Academy.
Original Link: original link
I'm here to make a supplement.
Implementation function: Scan to the recognition graph display model while playing the corresponding sound, remove the identification chart pause playback, and then recognition from the last place to start playback.

Basic Flow:
(1) Right-click on the blank of the hierarchy panel and select Create empty to make the null component (renamed to Audio_x).

On the audio_x component, right-select audio Sourse under Audio to add the audio Sourse component and rename it,

Drag the sound file into audio clip, and note that spatial Blend is best set to 3D, because the problem of space distance, not very good control, may cause your camera distance identification map too far, can not hear the sound.

(2) Drag the audio_x in step (1) to the corresponding imagetarget;

(3) Add a variable public audiosource audio to the Defaulttrackableeventhandler script on Imagetarget

Add the play and pause functions in the found and lost functions in the Defaulttrackableeventhandler script, respectively:

Play Code
if (!audio.isplaying)
{
   audio. Play ();
}
Pause Code
if (audio.isplaying)
{
   audio. Pause ();
}

Note: The most important point is here. This is I made a mistake, looked for a long time to find, do not know you will not forget, anyway, I have forgotten. is to add the audio Sourse component created in step (1) to the Defaulttrackableeventhandler script.

(4) If you get here successfully, you should be finished.
Note: 1. There must be an object in the scene with the audio Listener, otherwise you will not hear the sound, here Arcamera with.
2. The spatial blend option of the sound component is best set to 2D, so the volume size is not affected by the distance from the audio listener to the sound source.

The original paste has a demo project source code, you can download down to look.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.