This script is comparing 2 Vector3 (atleast it’s suppose to) and if they are similar the gameObject this script is attached to will be deactivated and will stop moving, I don’t know why this is not working.
using UnityEngine;
using System.Collections;
public class Learning : MonoBehaviour {
private Vector3 finalPosition = new Vector3 (3, 3, 3);
void Update () {
transform.position = Vector3.Lerp (transform.position, new Vector3 (3, 3, 3), 0.5f * Time.deltaTime);
if (Mathf.Approximately ((transform.position).magnitude, finalPosition.magnitude)) {
gameObject.SetActive (false);
}
}
}