- Home /
 
               Question by 
               Whelandrew · Jul 18, 2014 at 06:01 PM · 
                movementtranslate  
              
 
              Best Solution for Constant Horizontal Speed
I have a 2D object that will Translate to the left at a constant speed.
 void Update()
 {
     obstacleObject.transform.Translate(Vector3.left*(1*Time.DeltaTime),Space.World);
 }
The problem is that it increases in speed as the game runs. I know I've made this work in the past but I'm having a trouble remembering the process.
Thanks!
               Comment
              
 
               
              Answer by Saad_Khawaja · Jul 18, 2014 at 07:12 PM
 float speed = 5f;
     // Update is called once per frame
     void Update()
     {
          obstacleObject.transform.Translate(new Vector3(-(speed * Time.deltaTime),0f,0f));
     }
 
That's pretty much what I already have down. I tried your format (assigned a speed variable and manually assigned Vector3.left) but I'm getting the same result where the object speeds up after time. I need it to stay the same speed throughout.
It will not speed up after time. Are you sure you're not adding this script to a child object as well?
I am adjusting this value to a child object through the parent. Could this be the problem?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                