IfLookedAt Memory Problem
Hi, So I'm working with Google VR, I have this script:
It basically says that when I look at the object it will move to the desired position, It works fine but it causes a lot of lag on the phone, I was looking at the profiler and it uses a lot of memory, I have no idea of where and how to approach this problem, I hope you could help me, thanks!
 using UnityEngine;
 using System.Collections;
 
 public class LookingAtScript : MonoBehaviour {
 
     public Transform myself;
     public Transform Aquiputamadre;
     public float smoothTime = 0.3F;
     private Vector3 velocity = Vector3.zero;
     public float speed = 1f;
     private bool isLookedAt = false;
     public bool BridgeIsReadySir = false;
 
     public Transform cameralocator;
 
 
 
     float threshold = 0.1f;
 
     // Use this for initialization
     void Start () 
         
             {
                 //StartCoroutine (Planking (target));
             }
 
     void FixedUpdate()
     {
         if (isLookedAt && cameralocator.transform.tag == "Isla0")
         {
             StartCoroutine (Planking (myself));
 
 
         }
     }
 
     IEnumerator Planking(Transform myself)
     {
         Debug.Log ("Sip");
         while ((myself.transform.position - Aquiputamadre.transform.position).sqrMagnitude > threshold * threshold)
     {
         //if (isLookedAt)
         //{
                 transform.localPosition = Vector3.SmoothDamp (transform.localPosition, Aquiputamadre.localPosition, ref velocity, smoothTime);
                 Debug.Log (BridgeIsReadySir);
                 BridgeIsReadySir = true;
                 myself.GetComponent<Collider> ().enabled = false;
                 yield return null;
             //}
             //yield return null;
         }
         yield return null;
     }
 
     public void SetGazedAt(bool gazedAt) 
         {
             isLookedAt = gazedAt;
         }
     }
 
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                