Log in or register to post comments

Vuforia Bézier Pathfinding not moving with augmentation

March 22, 2019 - 5:42am #1

Hi there.



I've been trying to implement this path creator tool, which I've had a lot of success with in earlier non-ar projects.



The main issue I encountered when just using the plugin like any other, was that the path does not inherit the transform of its parent, so when the overall augmentation moves, the path is "stuck" in original unity space. 

I managed to create a script that tabs into the transform of the path and updates it based on another gameobject's transform which follows the augmentation.

here is the script:

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SetTransTo : MonoBehaviour
{
    public Transform targetTransform;
    private Transform temp;
    private Transform origin;
    public bool rotate;
    public bool position;
    public Vector3 reportedposition;
    public bool setVisualizertopath;
    private PathCreation.PathCreator pathCreator;
    public Vector3 pivot;
    void Start()
    {
        pathCreator = GetComponent<PathCreation.PathCreator>();
        pathCreator.bezierPath.Pivot = targetTransform.position;
        temp = targetTransform;
        origin = GetComponent<PathCreation.PathCreator>().transform;
       

        pathCreator.bezierPath.Position = targetTransform.position;
        pathCreator.bezierPath.Rotation = targetTransform.rotation;
        pathCreator.bezierPath.Pivot = targetTransform.position;

    }

    void Update()
    {
        reportedposition = pathCreator.bezierPath.Position;


        pathCreator.bezierPath.Pivot = targetTransform.position;

        pivot = pathCreator.bezierPath.Pivot;


        if (position)
            pathCreator.bezierPath.Position = targetTransform.position;
       
        if (rotate)
            pathCreator.bezierPath.Rotation = targetTransform.rotation;
       
    }
}

This script works fine when run in playmode. However there is one issue. When pressing play the transforms are not updated. As seen below the parent of the gameobject "eaglePath" is selected. - highlighted is the eagle following the path as set in unity 0.0.0 position:

eagle before selecting the path object

when playmode is paused, and i click the "EaglePath" it shows that the eagle is not following the path (probably because it updated the transform of the path when i select the game object):

if i then step forward one frame, the eagle follows the path immediately and if i unpause it works perfectly...

The update function runs (printing to console) but somehow all the transforms are not applied to the path unless the path has been selected ateast once in the editor. 

This means the path is also shifted/rotated out of order with the rest of the augmentation when building to android.



Any help would be apprechiated 



BR

Log in or register to post comments