I want Object A to move towards Object B at a certain speed. If possible I'd also like Object A to rotate towards Object B. If possible, answer so simply that a person who did not even understand the Unity Reference page can understand. Thank you.
Current script on ObjectA.
var speed = 4.0;
var ObjectB:GameObject;
function Update () {
}
Please do not link me to reference pages. Because they are never tailored to fit my situation. Thank you.
var speed = 4.0;
var ObjectB:GameObject;
private var increment:float;
private var rotation:Quaternion;
function Update () {
if(increment <=1)
increment += speed/100;
transform.position = Vector3.Lerp(transform.position, ObjectB.transform.position, increment);
//Add this block only if you want the rotation also be transitioned to objectB's rotation.
var direction:Vector3 = ObjectB.transform.position - transform.position;
rotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, increment);
}
Lerp function converts a Vector3 to another while increment goes to 1 from 0.