Hi,
I have some problems about moving an UI Image.
I used transform.position with Movetowards and time.SmoothDeltaTime and I tried too many things.
I have 2 main problems;
1-Moving was not smooth.
2- For new moving method, I need to reach screen boundaries according to new method used.
It will be easy to understand problem with watching the video.
Here the video Ekran Kaydı 2020-01-20 03.33.49.mov - Google Drive
Thanks a lot.
I suggest you look into a tweening engine such as leantween or dotween. It will help you a lot more with moving UI stuff especially. Otherwise, you really should show your code to have people help you with it.
IEnumerator Game.StartGame()
{
Vector2 RandomPosition = GetRandomPositionV2(0f, Screen.width, 0f, Screen.height, Obj.transform.position, 4f);
float RandomSpeed = GetRandomSpeed();
while (GameCenter.isPaused == false)
{
if (Vector2.Distance(Obj.transform.position, RandomPosition) > 3f)
{
Obj.transform.position = Vector2.MoveTowards(Obj.transform.position, new Vector2(RandomPosition.x, RandomPosition.y) ,RandomSpeed*Time.smoothDeltaTime);
//Obj.transform.DOMove(new Vector3(RandomPosition.x, RandomPosition.y, 0f), 1f, false).SetEase(Ease.OutCubic);
yield return new WaitForEndOfFrame();
}
else
{
Obj.transform.position = Vector2.MoveTowards(Obj.transform.position, new Vector2(RandomPosition.x, RandomPosition.y), RandomSpeed * Time.smoothDeltaTime);
RandomPosition = GetRandomPositionV2(0f, Screen.width, 0f, Screen.height, Obj.transform.position, 7f);
RandomSpeed = GetRandomSpeed();
yield return new WaitForEndOfFrame();
}
}
}
Thanks for the answer.
Basically, code is that.
Tweening did not worked for me. I already tried it.