GoogleVR / C# - How to, with the "pointer click": click 1 move a cube and click 2 move back the cube
Hello, First of all sorry for my English, it is a little rusty haha. I have a project where the goal is to make cubes move in function of scene. So it's clicking on a gameobject with a event trigger and a pointer click on it, who sets off two function who moves cubes.
Function 1 "cube" : this function is put in all the cube of the scene to set some property.
 public class Cube : MonoBehaviour
 {
 
     public float Distance;
     public Vector3 Direction;
     public bool IsCubeOpen = false;
 
     private Vector3 StartPos;
     private Vector3 EndPos;
 
 
     //time to go point A to point B
     public float lerpTime = 5;
     //this will update Lerptime
     private float currentLerpTime = 0;
 
     void Start()
     {
         StartPos = transform.position;
         EndPos = transform.position + Vector3.right * Distance;
     }
 
     // Update is called once per frame
     void Update()
     { 
         if (transform.position == StartPos)
         {
             IsCubeOpen = false;
         }
 
         if (transform.position == EndPos)
         {
             IsCubeOpen = true;
         }
 
 
     }
 
     public void MoveCube()
     {
         if (IsCubeOpen == true)
         {
             currentLerpTime += Time.deltaTime;
             if (currentLerpTime >= lerpTime)
             {
                 currentLerpTime = lerpTime;
             }
 
             float Perc = currentLerpTime / lerpTime;
 
             transform.position = Vector3.Lerp(StartPos, EndPos, Perc);
         }
         else
         {
             currentLerpTime += Time.deltaTime;
             if (currentLerpTime >= lerpTime)
             {
                 currentLerpTime = lerpTime;
             }
 
             float Perc = currentLerpTime / lerpTime;
 
             transform.position = -Vector3.Lerp(StartPos, EndPos, Perc);
         }
Function 2 "cubeprojet" : And the second function set all the cube involve with a tabler function and a call to the MoveCube public void of the first function. And have the public void "scene1" for the event trigger.
 public class cubeprojet : MonoBehaviour
 {
     public Cube[] mesCubes;
 
     private bool keyHit = false;
 
 
 
     // Start is called before the first frame update
     void Start()
     {
 
 
     }
 
     public void Scene1()
     {
         keyHit = true;
     }
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.A))
         {
             keyHit = true;
         }
         if (keyHit == true)
 
 
         for (int i = 0; i < mesCubes.Length; i++)
         {
             mesCubes[i].MoveCube();
         }
     }
 }
So for now i just achieved to move the cubes to one position but i don't know how to do the travel back to the original position. And that by cliking on the same button.
I hope all the information is there to help you find a solution that will help me a lot! Thank you for your attention and for your answers!
Your answer
 
 
             Follow this Question
Related Questions
OVR Walking Animation trigger. 0 Answers
Movement and Jump with animator 0 Answers
animator and script issue 0 Answers
How to send event to my canvas via script 0 Answers
Noob Here... Can you please give Script for moving a object into random Direction. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                