Hi, So I want that when the code reaches this part
_
"if (this.transform.localPosition == targetpos) "
_
stops checking Update() Function, I’m not sure if I should use the Update, but I have no idea, thank you for your help
void Update() {
if (isLookedAt)
{
transform.localPosition = Vector3.SmoothDamp (transform.localPosition, targetpos, ref velocity, smoothTime);
Debug.Log ("TestInside");
if (this.transform.localPosition == targetpos) {
Debug.Log("BUTTON HAS BEEN SELECTED!");
There is a chance that the check in the while never returns true because of float inaccuracy. If it is the case, check for a magnitude difference instead.
You could also use Lerp or MoveTowards which seem more appropriate for this purpose.