- Home /
 
               Question by 
               MIKIWAKAMISAMA · Nov 26, 2021 at 05:51 PM · 
                movementobjectbooleanboolmove an object  
              
 
              How do you make object stop after traveling a certain distance by pressing a key?
I want to make my object moving up and down by pressing key and stop, so that the object won't go out of the camera.
 public bool up;
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         up = !up;
         if (up)
         {
             //make object transform up and stop after certin distance
         }
         else
         {
             //make object transform down and if touch the ground, stop
         }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
3D Object Jump Glitch 0 Answers
I want to move the object more smooth way 1 Answer
How to Touch Drag 3D Objects 2 Answers
Need help with a pressure plate script (C#)(2D) 0 Answers
I'm having trouble setting a bool. 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                