Hey there, first the code is:
using UnityEngine;
using System.Collections;
public class Player_Move : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
void FixedUpdate(){
float move = Input.GetAxis ("Horizontal");
GetComponent<Rigidbody2D> ().velocity = new Vector2 (move * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}
void Flip(){
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
The problem is when character moves, for example if x axis is 1 and when I press right arrow, character goes instantly to, say 10 in the x axis and vice versa. It basically teleports. Kinda cool but not the thing I need.
Any ideas?