Log in or register to post comments

Reset Button for Ground Plane

March 27, 2018 - 4:01am #1

Hi everyone in this forum, hope you're having a nice time here.

 

I'll explain the current issue I'm experiencing in order to create a Reset button  for a ground plane screne in Unity with Vuforia. Here's the situation:

 

I have an UI with different buttons, 3 for placing objects in the current scene ( 3 differents) 2 buttons on the sides in order to rotate the objects (I need to finish this part because has to work in a different way than right now, but I have it working fine). The issue comes with the "Reset" button.

 

I'll expose the code regarding the reset and some details regarding it:

public class UserInterfaceButtons : MonoBehaviour
{
public float rotationSpeed = 70.0f;
public float translationSpeed = 5.0f;
    public Transform ObjAffected1;
    public GameObject ObjAffected2;
    public GameObject ObjAffected3;
    public Transform originalPosition;
// public GameObjects

    public Quaternion current;

    bool repeatRotateLeft = false;
    bool repeatRotateRight = false;

    public void Awake()
    {
        current = Quaternion.identity;
    }

    void Update()
    {
        if (repeatRotateRight) {
            RotationRightButton();
        }

        if (repeatRotateLeft) {
            RotationLeftButton();
        }
    }
    public void RotationRightButton()
    {
        // transform.Rotate (0, -rotationSpeed * Time.deltaTime, 0);
        ObjAffected1.transform.Rotate(0, -rotationSpeed * Time.deltaTime, 0);
        Debug.Log("rotate R");
    }


    public void RotationRightButtonRepeat()
    {
        // transform.Rotate (0, -rotationSpeed * Time.deltaTime, 0);
        repeatRotateRight = true;
        Debug.Log("rotate R2");
    }
    public void Restart() {
        Debug.Log("reset");
        Quaternion.identity.Set(current.x, current.y, current.z, current.w);

        /*Quaternion currentRotation = new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z, 0);
        currentRotation = current;*/
        //This is a test string regarding transform.rotation
    }

 

What I want to achieve is the reset button, that means reset the object rotation and respecting the location of the following: AR Camera, Ground Plane Stage and also Plane Finder, as this scene will be applied with Ground plane detection. This means that the rotation has to be reseted and the object has to be removed from the scene or at least dissapear from it.

 

As much as I investigated regarding it, looks like Quaternians are needed in order to do this kind or workflow. I'm not that familiar with them and finding guides regarding it is really complicated, hope you guys can provide me some help in order to keep advancing on my current project.

 

Thanks for your help and looking forward to hearing from you. Kind regards.

 

EDIT: I've already solved it. Thanks anyway. Can close the post.

 

 

 

 

Reset Button for Ground Plane

May 3, 2019 - 11:59am #4

Hello,

The Vuforia Engine Core samples on the Unity Asset Store have a reset button associated with the Ground Plane feature to reset the tracker. This is the best reference code resource that is available to you IMO.

Thanks,

Vuforia Engine Support

Reset Button for Ground Plane

May 1, 2019 - 8:27pm #3

Please share the reset button solution if possible.  It would help greatly.  Thank you!

Reset Button for Ground Plane

May 1, 2018 - 10:00am #2

would you mind sharing the solution. Im new at vuforia and unity, been able to load my scene when you open the app, but when running into tracking issues decide to restart the app, it will be more convenient to have a restart app button... or anything in that sort. Your help will be highly appreciated. 

 

thanks!

Log in or register to post comments