- Home /
 
 
               Question by 
               unity_E485052FE8918F5A47A9 · May 11 at 01:13 PM · 
                scripting problemupdatescripting beginner  
              
 
              Extracting Values from Update Function
Hello all, I am working on getting values in euler angles which is an array of 3 elements double [] Euler= double new Euler [3] that will be updated in the Update Function, In the console I can see the values constantly changing. Is there any way I can access these values. for example I want to set a condition in the update, if (previous euler angle > next euler angle ) {
 Do Something; } I know that, the update function updates once/frame so how can I get the euler angle values in the previous frame. Could you please help? 
               Comment
              
 
               
              Answer by RamaKrishna39 · May 17 at 12:52 PM
This might help. Check once!
     Vector3 cur_angle; // angle from current frame
     Vector3 prev_angle; // angle from previous frame
 
     // Start is called before the first frame update
     private void Start()
     {
         prev_angle = transform.eulerAngles;
         cur_angle = transform.eulerAngles;
     }
     // Update is called once per frame
     void Update()
     {
         cur_angle = transform.eulerAngles;
         func(cur_angle);
     }
 
     void func(Vector3 cur_angle)
     {
         if(prev_angle.z > cur_angle.z)
         {
             //Do something
         }
         prev_angle = cur_angle;
     }
 
              Your answer