Hey there,
I am developing my a Vuforia based AR experience using image targets. When scanned, there will be a 3D building pop up.
The target itself will be a wall poster, but also sent to clients as a postcard. So it will sometimes be scanned vertically and sometimes horizontally.
Is there a way to force the 3D model to always be oriented to Y up no matter which way the target is?
Hope that makes sense.
J
If by ‘Y up’ you mean upwards in WorldSpace, you can use transform.LookAt(Vector3.up, transform.forward) to reset the up-vector.
If you’re trying to get it to point ‘upwards’ from a plane, use the Up-vector of the plane’s transform instead of Vector3.up
Thanks for your reply,
I’m pretty sure what I want is your first answer, world space.
My scripting skills are poor, so would you be able to help me with how to format this in a script?
Do I just add transform.LookAt(Vector3.up, transform.forward) to the public section of a blank script or do I need to define any variables?
Thanks for your help
That depends on how you’re spawning the Object.
If you’re spawning it yourself (using Instantiate(prefab)), then you can do it directly after instantiation (using the .transform from the object you just spawned).
If the Object is being spawned automatically, you can add it to the Start()-Method of the custom prefab that you have set.
Thanks, I’ll let you know how I get on