Easyar NavMeshAgent fuction has not working properly!AnyOne Have achieving it???

0 votes
asked Oct 13, 2019 by grissankara (690 points)
We want use click to move function achieving navmeshagent..its very well working in normal .when i move to ar mode the model change rotating and position so i got some error to not achieving the actual result..anyone have achieving the navmesh agent in easyar3.0..in 2.0 very well functioning but when i upgrading i got errors like...set position call only navmeshagent active itself???

1 Answer

0 votes
answered Oct 23, 2019 by emanuel (390 points)
Easy AR, and other AR SDK as well, moves the camera and the objects in order to create the virtual reality effect. This way, when you try to use a navmesh, particles ou certain types of animation, it may not work as espected. But you can change your settings in a way that fits you.

For example, in my case, I've changed the ImageTrackerBehaviour CenterTarget to "FirstTarget", this way only the camera moves.

I've also changed a line in the ImageTrackerBehaviour to rotate the object in the AR.

pose = args.ImageRotationMatrixGlobal * pose * Matrix4x4.Rotate(Quaternion.Euler(-90, 0, 180));

You may change the values in "Quartenion.Euler" to achieve your desire.
commented Oct 23, 2019 by grissankara (690 points)
Thanks for your Answer.Can you please share your script....
commented Oct 23, 2019 by emanuel (390 points)
using easyar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

class ImageTrackerBehaviour : easyar.ImageTrackerBehaviour
{
    public override void UpdateFrame(ARSessionUpdateEventArgs args)
    {
        List<ImageTargetController> currentTrackingControllers = new List<ImageTargetController>();
        var results = args.OFrame.results();

        foreach (var _result in results)
        {
            ImageTrackerResult result = null;
            if (_result.OnSome)
            {
                result = _result.Value as ImageTrackerResult;
            }

            if (result != null)
            {
                var targetInstances = result.targetInstances();
                int centerTargetId = -1;
                if (TargetCamera == null)
                {
                    Utility.SetMatrixOnTransform(Camera.main.transform, centerTransform);
                }
                else
                {
                    Utility.SetMatrixOnTransform(TargetCamera.transform, centerTransform);
                }
                if (CenterImageTarget != null && CenterImageTarget.Target() != null && CenterTarget == CenterMode.SpecificTarget)
                {
                    centerTargetId = CenterImageTarget.Target().runtimeID();
                }
                foreach (var targetInstance in targetInstances)
                {
                    var target = targetInstance.target();
                    if (!target.OnSome)
                    {
                        continue;
                    }
                    var status = targetInstance.status();
                    foreach (var targetController in targetControllers)
                    {
                        var _target = targetController.Target();
                        if (target.Value.runtimeID() == _target.runtimeID())
                        {
                            if (status == TargetStatus.Tracked)
                            {
                                if (!targetController.Tracked)
                                {
                                    targetController.OnFound();
                                    targetController.Tracked = true;
                                }
                                var pose = Utility.Matrix44FToMatrix4x4(targetInstance.pose());

                                pose = args.ImageRotationMatrixGlobal * pose * Matrix4x4.Rotate(Quaternion.Euler(-90, 0, 180));

                                if (CenterTarget == CenterMode.FirstTarget && centerTargetId == -1)
                                {
                                    centerTargetId = target.Value.runtimeID();
                                    CenterImageTarget = targetController;
                                }

                                if (centerTargetId != target.Value.runtimeID())
                                {
                                    pose = centerTransform * pose;
                                    targetController.OnTracking(pose);
                                }
                                else
                                {
                                    targetController.OnTracking(Matrix4x4.identity);
                                    centerTransform = pose.inverse;
                                }
                                currentTrackingControllers.Add(targetController);
                            }
                        }
                    }
                    target.Value.Dispose();
                    targetInstance.Dispose();
                }
                result.Dispose();
            }
        }
        foreach (var targetController in targetControllers)
        {
            bool contain = false;
            foreach (var item in currentTrackingControllers)
            {
                if (item == targetController)
                {
                    contain = true;
                }
            }
            if (!contain && targetController.Tracked)
            {
                targetController.OnLost();
                targetController.Tracked = false;
            }
        }
    }
}
commented Nov 26, 2019 by grissankara (690 points)
It's perfectly worked for single target single recognition but come into multiple targets and multiple recognition not very well working..is there any code for multiple recognition???
commented Nov 27, 2019 by emanuel (390 points)
I haven't really testet the code fot multiple recognition, I'll give it a try and change it in order the make everything work just fine.

Thanks for your feedback.
commented Dec 1, 2019 by grissankara (690 points)
if i use collision based 3dmodel it will be affected position of 3models..when i goes to tracking lost nd then come back to tracking the model change the position itself...can u share your code if u find any ideas about multiple recognition.
Thanks.
commented Dec 6, 2019 by emanuel (390 points)
I haven't been able to test it yet, but if you share your project I would be able to test it directly and then share my results.
Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...