How to activate animations in AR with touch input using Vuforia AR & Unity3D

Sdílet
Vložit
  • čas přidán 28. 08. 2024
  • How to activate/start animations in AR with either touch input or keyboard press using Unity3D and Vuforia. Simple touch input on a phone.

Komentáře • 52

  • @CubicBrain
    @CubicBrain  Před 5 lety +17

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class animHDD : MonoBehaviour {
    public Animator anim;
    // Use this for initialization
    void Start () {
    }
    // Update is called once per frame
    void Update () {
    /* if(Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("none"))
    {
    anim.Play("open");
    }
    else if (Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("close"))
    {
    anim.Play("open");
    }
    else if (Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("open"))
    {
    anim.Play("close");
    }*/
    for (int i = 0; i

  • @123456789jameswhite
    @123456789jameswhite Před 5 lety +2

    Hey, great video. how would you do this for multiple image targets if you wanted to trigger them independently?

  • @pauldouglas6931
    @pauldouglas6931 Před 6 lety +1

    Another brilliant tutorial - thanks!

    • @CubicBrain
      @CubicBrain  Před 6 lety +1

      Thanks a lot Paul.

    • @abdulmajidmyarima418
      @abdulmajidmyarima418 Před 4 lety

      @@CubicBrain good day and nice to meet you can we talk please so that you can assist me am working on AR for my final year project

  • @aegiswang1
    @aegiswang1 Před 5 lety +1

    Thank you!! It's very helpful!!

  • @jacobyoung6876
    @jacobyoung6876 Před 6 lety

    Once again, great video!
    I had always wondered how accessing mobile touch worked. Where did you learn to program for touch?
    I'm looking to get started using different kinds of touch commands (such as pinch) to scale objects in Vuforia.
    If you have any advice, please let me know!

    • @CubicBrain
      @CubicBrain  Před 6 lety

      Hi Jacob, thanks once again for the feedback. I don't have a lot of experience with touch commands, but its actually on my list of future features to build, and make a tutorial about.

  • @problemsinspace
    @problemsinspace Před 6 lety +1

    These are great videos. Thanks.

  • @davechaffey3493
    @davechaffey3493 Před 5 lety

    Great explanation. Kudos to you!

  • @0099boomerang
    @0099boomerang Před 3 lety

    Can we use interface slider for triggering and controlling AR object animations?

  • @disconuts315
    @disconuts315 Před 11 měsíci

    I know it's a long shot this video is 5 years old but i can't for the life of me find a way to trigger a sound when the screen is touched, could you help me?

  • @xc5838
    @xc5838 Před 5 lety

    Thank you so much for posting this video this was exactly what I was looking for. I would also like to ask you a follow-up question. How can you detect a user's touch on a mobile device on a specific part of the 3D model? For example, I only want to play the open animation after pressing the 3rd square from the first row and only play the ending animation on the last square from the last row. Can this be done?

    • @CubicBrain
      @CubicBrain  Před 5 lety

      Hi Luke, thanks a lot. Sure. I made a video where you use ray-casting to check for collisions with 3D obejcts (and use it as triggers): czcams.com/video/hi_KDpC1nzk/video.html

  • @leabarrionuevo
    @leabarrionuevo Před 4 lety

    hi! thanks for your videos, they are amazing. In this moment, i want to do the same but with a touch cube (and reproduce the animation), how do i do it?

  •  Před 5 lety

    you could create a tutorial so that when you press the screen a video will be put on full screen, thanks

  • @miqdadagilamarullah
    @miqdadagilamarullah Před 5 lety

    Is that 3d from blender?

  • @jagdelhi
    @jagdelhi Před 4 lety

    Could u suggest some script in unity Vuforia AR, that starts animation onTrackingFound and restart on another time
    ...

  • @WBBG1
    @WBBG1 Před 6 lety

    Great Video! Do you have any tips or walkthroughs on how to implement this using the ground plane feature? Currently, if you try to use touch input on a model using ground plane, it just clones the model. Is there a way to interact with ground plane models using touch input? Thanks!

    • @CubicBrain
      @CubicBrain  Před 6 lety

      Hi Terry, I havn't yet tied the ground plane feature, but I am pretty certain that I will make a video about it in the future.

  • @csellers900
    @csellers900 Před 2 lety

    I'm a bit of a noob inside of unity. Am I missing something? None of the models I import into unity have the Model, Rig, Animation, Materials tabs inside the Inspector window. I can access their animations inside the animator window but the inspector window just shows Tag, Prefab, Transform, and Animator.

    • @CubicBrain
      @CubicBrain  Před 2 lety +1

      Your animation might already be set up in the imported model. You seem to be viewing a prefab, and not the actual model. In the video I use an imported FBX file where the animation is stored as a "clip"

    • @csellers900
      @csellers900 Před 2 lety

      @@CubicBrain It was a rigged/animated game model I bought from sketchfab and imported using their store plugin. It uses separate fbx files for all the animations. At first I thought I was selecting the wrong object in the object tree but none of the underlying layers have those features. Does this mean I have to manually import the fbx and re-setup all the animations inside it?

    • @CubicBrain
      @CubicBrain  Před 2 lety

      @@csellers900 you might have to. if you can import the FBX with animations in them you should be able to find them in the project folder and just add them to the animation controller of your main object

    • @csellers900
      @csellers900 Před 2 lety

      @@CubicBrain Thanks for the response! I tried creating a new blank 3D project and did a generic import of the same model but I still don't have those options available so I tried importing other random fbx files that have animations and none of them have that option available in the Inspector tab. I'm at a loss on what's causing this but I'll update if I ever figure it out.

  • @JoshyHJoshy
    @JoshyHJoshy Před 6 lety

    Hi there, There are some AR apps around that when you hover the tablet on an engine part, for example, some animation starts playing, for instance how to dismantle that part or how to fix it, as well as instructional text on top of the real object. Is it the same principle as this tutorial, that instead of an image target (marker) a 3D object is recognized and then some animation is played or text is shown? Can Vuforia does this?

    • @CubicBrain
      @CubicBrain  Před 6 lety +1

      Hi, it is kind of the same principle, however the shown functionality is only for image targets (flat surface). Vuforia has recently updated, and now support model targets (3D models), however I have yet to test this new feature.

  • @miqdadagilamarullah
    @miqdadagilamarullah Před 5 lety

    How can i export .fbx with texture

  • @katermurr
    @katermurr Před 4 lety

    Trying to find a way to combine this script with my Audio clips (with loop). No luck so far. do you have some hints or did anyone already implement this?

    • @katermurr
      @katermurr Před 4 lety

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class BowAnim : MonoBehaviour {
      public Animator anim;
      AudioSource myAudio;
      // Use this for initialization
      void Start () {
      anim = GetComponent();
      }

      // Update is called once per frame
      void Update () {

      /* if(Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("none"))
      {
      anim.Play("jump");
      }
      else if (Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("idle"))
      {
      anim.Play("jump");
      }
      else if (Input.GetKeyDown("1") && anim.GetCurrentAnimatorStateInfo(0).IsName("jump"))
      {
      anim.Play("idle");
      }*/

      for (int i = 0; i

  • @adithyasathya2578
    @adithyasathya2578 Před 6 lety

    Hey there.
    I just have a few questions...
    So I have made an fbx animation from a blender asset that uses virtual button. When it play, some objects in the asset dissapear if you get really close to the object.
    Is there a way to fix this bug?
    Also can the touch input in this video be paired to a on-screen button? And is there a tutorial for that.
    I would likd to also request a video on UI in an AR app?
    Thank you so much.

    • @CubicBrain
      @CubicBrain  Před 6 lety +2

      Hi, Regarding the distance of the object to the ARCamera, you should be able to fix this by changing the "Clipping Planes" for the camera in the settings for it inside the inspector.
      The simple touch input in this tutorial is only for one animation or function at a time, as it only checks if the screen has been touched.
      If you want a UI and/or button you will have to use ray casting. I am currently planing a tutorial with simple touchscreen UI and ray casting, but I haven't recorded it yet.

    • @adithyasathya2578
      @adithyasathya2578 Před 6 lety

      CubicBrain Thank you!
      I tries to build the app to test it on my surface pro pc, but after the Unity logo, the app is just a black screen. It doesn't ask for camera permission. How do I fix this?

    • @CubicBrain
      @CubicBrain  Před 6 lety

      Hi, I don't know if the Surface pro webcam driver is supported in Vuforia. You might want to ask their tech support or forum at their site.

  • @rebekahbottjen7816
    @rebekahbottjen7816 Před 4 lety

    For some reason this is not working in my project.

    • @CubicBrain
      @CubicBrain  Před 4 lety

      Make sure, that the Spelling and case of the animation name is correct.

  • @emporato
    @emporato Před 6 lety

    Could you give us the text content of the script or the script file itself...? I am kind of new at unity... thanks in advance

  • @jonhgcan4398
    @jonhgcan4398 Před 6 lety

    How can i use multiple VirtualButtons to play an animation? So far i got to work only 1 button. Is a simple exercise of jump,atk and block on a 3d mode.. Anyone have a documentation for the virtual buttons or an idea of how to manage them in code?

    • @CubicBrain
      @CubicBrain  Před 6 lety

      Hi John, in my video about virtual buttons you can just add more gameobject variables in the code, or set up an array of buttons. czcams.com/video/ElmzIq6stNI/video.html&lc=Ugx4ULl8UPIbRMfDay14AaABAg it this what you are looking for?

    • @jonhgcan4398
      @jonhgcan4398 Před 6 lety

      yeah,Thanks!!! :D with that video i made my button but could not figure how to control more buttons to do trigger differents animation depending on wich was "pressed", somewhat a mix between both videos.

    • @CubicBrain
      @CubicBrain  Před 6 lety

      If you create more buttons, you can just make a new set of functions in the update (including a VbBtnObj2 gameobejct variable) then you should be able to add the new buttons, and trigger their functions.

    • @jonhgcan4398
      @jonhgcan4398 Před 6 lety +1

      i was able to do it like that :D thanks for the responses and the help, appreciated very much !!!!!!!!!!!!

  • @munzimukhtar763
    @munzimukhtar763 Před 6 lety

    i get n error line under IsName , i dont know why

    • @CubicBrain
      @CubicBrain  Před 6 lety

      Hi Munzi, could you be a bit more specific? what does the console say?