Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

MAXST & Billboard scripts

Discussion in 'AR' started by MartinAnd, Feb 6, 2020.

  1. MartinAnd


    Jan 11, 2018

    We are using MAXST ImageTracker feature in our team now for almost a year in our Android and iOS application and are very happy with it. However, we experienced a strange behavior in connection with Billboard scripts.
    I have read a lot of forum articles and also had a look into how quaternions are working in the last week, but wasn't able to find the cause for these problems and neither find a way to fix it.

    These are the things i have problems with.

    1) Result in editor and on device is different(90° rotation on devices)
    2) Lock axis(preferable Z axis but also X or Y axis, or a combination of all axis)
    3) Consider the parents and the initial rotation of the gameobject.

    We are using:
    Unity 2018.4.6f1
    MAXST 4.1.4

    Make a new Unity Project and download the MAXST 4.1.4 framework. Register and get a free serialnumber for image tracking with a maxst watermark.
    Import the unitypackage, set the package name to the name you chose on the maxst website.
    Open the ImageTracker scene from the examples, select the ar camera gameobject, go to config in the inspector and insert your serial number.
    Exchange the child object of the first ImageTrackable with the Billboard prefab and the second ImageTrackable with the BillboardRotated prefab.
    In these prefab, i have a collection of different billboard scripts i found on the web. 3 of them are from the Unity Wiki and one is from the Microsoft MixedRealityToolkit and one mixed from an forum post.

    1) If we have a look at the Billboard Prefab in play mode in the editor everything looks like this. UnityEditor.png
    This is what we expected to see. The object is following the orientation of the camera and you can read the text from every angle.
    Lets deploy it on an android device and see whats happening. Screenshot_20200205-184157_MaxstTest[1].jpg
    Not what we expect. Everything is rotated by 90° at the Z axis. Although we have portrait mode in the editor and in the app.
    The thing what i came up with was, checking if the app is running in the editor or not and if not, adding an offset of 90 degree's on the Z axis, with this code at the and of every billboard script.

    transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x,
    transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z + 90);

    I don't think this is the right way to solve this behavior. I would prefer to find the cause, because i think this is also the reason for the other problems.

    How can i achieve to react it the same in editor and on the device?

    2) As you found out, the billboards are following the camera movement and this also means, if i am rotating the phone on the Z axis, the billboards follow. In my case the billboards should only rotate on the X and Y axis and shouldn't rotate on their Z axis.
    If we have a look at the MixedRealityToolkit Billboard script(Billboard.cs), we see the option to select "Pivot Axis" if we choose "XY", so the Z axis should be locked.
    If we set it that way nothing happens. It rotates on every axis as before where it was on "free", although it should only rotate on the X and Y axis...

    What am i doing wrong? Why isn't it working? Or should i extend one of the other billboard scripts with a couple of extra lines of code?

    3) Lets change to the other prefab "BillboardRotated"...
    Assume, that i have a big 3D model right under the "ImageTrackable" gameobject with a big hierarchy and a lot of rotated objects in it. Somewhere in the 5th or more level from the top hierarchy, where al parents have some sort of rotation in any axis, i have an element where i want to use the billboard script. Also i have an initial rotation on the element for some reason. Here i want to use the option to lock the Z axis and X axis, so it only rotates on the Y axis, without overwriting the initial rotation.

    Sorry for the long post, i hope everything is clear.

    Would be great if you could help me.

    Thanks in advance, Martin.

    Attached Files: