- Home /
Player Sliding forward when moving Horizontal
Not sure whats going on but I have a player who only can move Left/Right the code works fine but as my player moves it slides forward. Not sure whats going any help would be appericated.
var touch = Input.GetTouch(0);
// left
if ( touch.phase == TouchPhase.Began && touch.position.x < Screen.width/2)
{
direction = Vector3(transform.position.x, 0, -90);
player.transform.LookAt(transform.position +1*direction); //look the right way
player.transform.Translate(Vector3.forward * 3* Time.smoothDeltaTime);
animation.CrossFade("Run");
}
Comment
Answer by HarshadK · Jan 28, 2015 at 07:28 AM
I think you need transform.forward instead of Vector3.forward inside your Translate to move the player in the direction it is facing. Like:
player.transform.Translate(transform.forward * 3* Time.smoothDeltaTime);
Your answer
![](https://koobas.hobune.stream/wayback/20220613181735im_/https://answers.unity.com/themes/thub/images/avi.jpg)