Log in or register to post comments

How to make on Android vibration and beep when it detects the im

December 10, 2012 - 2:33am #1

Hello, please help a newbie, how to make on Android vibration and beep when it detects the image Target? Thanks in advance.

That's a good idea. That is a

December 22, 2012 - 2:09pm #14

That's a good idea. That is a Unity Editor error arising from the Inspector for your audio clips. It seems that the waveform textures aren't being found, which is resulting in an empty array, hence the IOR error. So something is corrupting your project in the Editor.

Another option is to try Assets > Reimport All.

I would suggest trying to

December 21, 2012 - 11:42am #13

I would suggest trying to isolate the "beep sound" problem by creating a brand new project from scratch (e.g. by importing the ImageTargets) sample and then for instance just add a Sound that is played upon a Button touch (instead of upon OnTrackingFound());

if you setup things incrementally it might be easier to identify the problem.

 

  The problem with the sound

December 20, 2012 - 9:40pm #12

 

The problem with the sound strange, after the transition to Vuforia 2, do as described below, everything works fine when testing in the Unity sound is played, but as soon as I start to compile the apk for Android, when compiling an error - IndexOutOfRangeException: Array index is out of range.UnityEditor.AudioClipInspector.CombineWaveForms (UnityEngine.Texture2D [] waveForms) (at C :/ BuildAgent/work/812c4f5049264fad/Editor/Mono/Inspector/AudioClipInspector.cs: 284)UnityEditor.AudioClipInspector.RenderStaticPreview (System.String assetPath, UnityEngine.Object [] subAssets, Int32 width, Int32 height) (at C :/ BuildAgent/work/812c4f5049264fad/Editor/Mono/Inspector/AudioClipInspector.cs: 83)UnityEditor.AssetPreviewUpdater.CreatePreviewForAsset (UnityEngine.Object obj, UnityEngine.Object [] subAssets, System.String assetPath) (at C :/ BuildAgent/work/812c4f5049264fad/Editor/Mono/AssetPreviewUpdater.cs: 33)UnityEditor.HostView: OnGUI ()

Apk but compiles and runs on the phone, but with no sound, and when compiled with this error sound stops working, and when you test on Unity, how to overcome?

How to make on Android vibration and beep when it detects the im

December 12, 2012 - 12:54pm #11

How to make on Android vibration and beep when it detects the im

December 12, 2012 - 7:25am #10

Hi, if you don't hear the sound, it might be a volume problem with the Audio Source component.

In particular, it could be that your sound volume is decreasing with your camera distance from the target (as it is a 3D sound)

In the inspector please check/change the following:

- Play on Awake checkbox:  disabled

- Audio Clip: correctly filled in with your MP3 clip

- Volume: 1

- 3D Sound Settings:

      -> Volume Rolloff: if it is set to Logarithmic Rolloff => change to Linear Rolloff

         -> Min Distance: 1

         -> Max Distance: 5000 (probably by default this is set to 500)

 

Try that, it should fix the problem (I had a similar volume issue, and was fixed with those settings)

 

 

How to make on Android vibration and beep when it detects the im

December 12, 2012 - 6:10am #9

But why is the sound I have a problem, did everything as you described below, but the sound does not play, vibration works but no sound ...

use audio format mp3 length less than a second

 

 

How to make on Android vibration and beep when it detects the im

December 12, 2012 - 5:43am #8

Thank you very much!) It works! adjust the strength of vibration possible?

How to make on Android vibration and beep when it detects the im

December 12, 2012 - 5:38am #7

You're welcome!

about vibration strength, the Unity Handheld API does not allow for that.

By programming on Android natively, it would be possible to control the vibration "duration" though (if that's of interest to you), but not the strength AFAIK.

however, to make it work in Unity you will need to first code it in Android and then make an Android Plugin that you call from Unity; this is not difficult to do, but a bit more involved. You can check on the Unity website on how to perform such integration (Unity / Android Plugin) if youre interested.

 

 

How to make on Android vibration and beep when it detects the im

December 11, 2012 - 6:36am #6

Just clarifying a bit more on the Audio part (refer to my previous message for the Vibration part):

- add an Audio Source component to the same ImageTarget in which you added the vibration script

- In the Inspector view of the Image target - Audio Source, disable the "Play on Awake" checkbox

- Set an audio file in the "Audio Clip" field of the Audio Source (in the Inspector view); if you don't have an audio clip (for the beep sound), download one clip from the internet and save it under the "Sounds" directory under your project directory; this will make the clip appear in the Assets list in your project, so that you can drag and drop the audio clip onto the "Audio Clip" field of the Audio Source component

- Modify the OnTrackingFound code snippet as follows:

private void OnTrackingFound()
    {
  Handheld.Vibrate ();
  AudioSource audioSource = (AudioSource)GetComponentInChildren<AudioSource>();
  if (audioSource)
  {
   audioSource.Play();
  }
  
  Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    } 

This will do the trick.

How to make on Android vibration and beep when it detects the im

December 11, 2012 - 6:18am #5

Hi, you can follow these steps to make the phone vibrate upon target detection:

- create a new C# script (e.g. call it "VibrationTrigger")

- attach the script to your Image Target (e.g. to the "Chips" image target, etc.)

- in the script, make your class implement extend the MonoBehaviour and also implement the ITrackableEventHandler interface

- put this code in your script (note the Handheld.vibrate() function called in the OnTrackingFound() function):

public class VibrationTrigger : MonoBehaviour, ITrackableEventHandler {
    private TrackableBehaviour mTrackableBehaviour;
 
    void Start()
    {
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }

        OnTrackingLost();
    }

   
    // Implementation of the ITrackableEventHandler function called when the
    // tracking state changes.
    public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED)
        {
            OnTrackingFound();
        }
        else
        {
            OnTrackingLost();
        }
    }

    private void OnTrackingFound()
    {
        Handheld.Vibrate ();
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
    }

    private void OnTrackingLost()
    {
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
    }

}

That will make your device vibrate; in order to play a beep sound, you can just add the audio playback code next to the Handheld.vibrate() function call.

 

How to make on Android vibration and beep when it detects the im

December 11, 2012 - 3:44am #4

Well, in general it can be through anything, the main thing to get what I need, I did not try as I do not get (

How to make on Android vibration and beep when it detects the im

December 11, 2012 - 3:31am #3

Preferably with Unity)

How to make on Android vibration and beep when it detects the im

December 10, 2012 - 3:49am #2

Hi, do you want to do this from Unity or from Android natively ?

Log in or register to post comments