- Home /
I'm trying to make a UI object move from one position to another over time
I have an image acting as the object I want to move as a test. Eventually what I want to do is make the test image become a mask for another image that will act as the object moving underneath it. I'm also hoping to implement an if statement to check if the image has reached a certain point and then resets the image back to its original position. My problem is that when I run the game client, my script causes Unity to stop responding and basically crash.
This is the script in question. Any help on why its doing this and advise on how to change it would be appreciated.
public Image world;
public Vector3 v1 = new Vector3(1, 0, 0);
public Vector3 v2 = new Vector3(178, 0, 0);
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
while (world.transform.position != v2)
{
world.transform.position += v1;
}
if(world.transform.position == v2)
{
world.transform.position = v1;
}
Your answer
Follow this Question
Related Questions
Getting a different transform position value 1 Answer
[Solved]Why my Unity Button's Positions are different. 1 Answer
Canvas button transfrom position not correct 0 Answers
Image ui point at mousse position 0 Answers
How to store position in a variable and than edit only specific part of it(such as 'x') 1 Answer