B
B
BadCats2017-10-15 16:02:44
Unity
BadCats, 2017-10-15 16:02:44

Rotate ui behind camera?

There is a Canvas on the scene with an Image in it - the Canvas is a child of the camera and rotates behind it - but the problem is that the Image doesn't rotate behind the camera, but is a child of the Canvas - why?
well, I need the ui to move behind the camera in vr - like a pointer
59e364a4984ae696598510.jpeg
I'm surprised why the following script does not work for the orange circle

GameObject ParentTransform = transform.parent.gameObject;
    transform.position = new Vector3(ParentTransform.transform.position.x, ParentTransform.transform.position.y, ParentTransform.transform.position.z);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BadCats, 2017-10-15
@BadCats

Found a solution:

void RotAin()
    {
        int x = 1;
        if (x==1)
        {
 gameObject.transform.position = new Vector3(transform.rotation.w, transform.rotation.w, gameObject.transform.position.z);
            x++;
        }
        else
        {
            gameObject.transform.position = new Vector3(transform.rotation.w, gameObject.transform.rotation.y, gameObject.transform.position.z);
        }
       
    }

and - call in Update void RotAin()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question