Question by
Bhargav5530 · Sep 02, 2015 at 11:02 AM ·
vector2movetowards
How can I use Vector2.MoveTowards to UIElements
Hello unity users,
I have an UI Image and I want to give the transition effect to it. So I search on internet and I found the Vector2.MoveTowards() function. But I don't know how to use it with RectTransform component.
does any one help me?
Here I am pasting a demo code of transform. Can someone edit and post an answer for how to use it with RectTransform.?
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Transform target;
public float speed;
void Update() {
float step = speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target.position, step);
}
}
Comment
Your answer
Follow this Question
Related Questions
Vector2.MoveTowards not working. 0 Answers
How to move more than one object together at a time? 1 Answer
How to use Vector2 movetowards? 1 Answer
Vector2.MoveTowards works strangely 0 Answers
Vector2.moveToward 0 Answers