Question by
juasjuasie · Oct 21, 2019 at 02:07 PM ·
canvastween
How to move panel canvas to the center of the screen?
I am trying to translate the panel from a canvas to center of the screen (relative to the position of the camera):
private void Update()
{
if( transform.position.x >= Camera.main.ScreenToWorldPoint(
new Vector3(Screen.width/2,
Screen.height/2,
Camera.main.nearClipPlane)).x)
transform.position += Vector3.left * 100 *Time.deltaTime;
}
However, what i get is the panel translating to the left ad infinitum, as if the center in x does not exist.
Comment
Your answer
Follow this Question
Related Questions
Lerp Random Position - Within Original Vector3 1 Answer
Does setting SetActive(true) in parent GameObject sets CanvasRenderer alpha of child objects to 1? 2 Answers
Problem rendering an image in a canvas 0 Answers
Canvas elements missing on certain computers 0 Answers
Android application/game with screen transition ... 0 Answers