- Home /
 
 
               Question by 
               KamaSystems · Feb 17, 2019 at 08:26 AM · 
                movementvector3smoothtransform.translate  
              
 
              C# Smoothing Out transform.Translate
Hi everyone, is there a way to smooth out transform.Translate? I have a script where ball is moved forward and left on click with tansform.Translate(dir * speed *Time.deltaTime); but it feels very jagged and unnatural. Here is a part of code:
 if(Input.GetMouseButtonDown(1) && !isDead){
 
             isPlaying = true;
             btnfx[0].Play ();
             score ++;
             scoreText.text = score.ToString ();
             if(dir == Vector3.forward){
 
                 dir = Vector3.left;
             }
             else{
 
                 dir = Vector3.forward;
             }
         }
 transform.Translate (dir * speed *Time.deltaTime);
 
              
               Comment
              
 
               
              You could always try Time.smoothDeltaTime, or the LateUpdate function ins$$anonymous$$d of update. Also you could use
 transform.position = Vector3.$$anonymous$$oveTowards(transform.position + (dir * speed *Time.deltaTime), speed * Time.deltaTime);
 
                  Or you could use a rigidbody and move it with physics. Plenty of options really.
Your answer
 
             Follow this Question
Related Questions
How to smooth my camera (Vector3.Lerp) 0 Answers
Change in position going up not smooth 1 Answer
How to smooth movement object in one-axis? 1 Answer
Vector3 wont move to right position 0 Answers