Question by
felixeagle · Jul 07, 2019 at 12:31 AM ·
2d-platformerplayer movement2d animationleftright
What are the errors I'm making and how do I fix them
public class Player : MonoBehaviour { private Rigidbody2D myRigidbody;
[SerializeField]
private float movementSpeed;
private bool facingRight;
// Start is called before the first frame update
void Start()
{
facingRight = true;
myRigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate()
{
float horizontal = Input.GetAxis("Horizontal");
HandleMovement(horizontal);
}
private void HandleMovement(float horizontal)
{
myRigidbody.velocity = new Vector2(horizontal * movementSpeed, myRigidbody.velocity.y);
}
private void flip(float horizontal);
}
if (horizontal > 0 && !facingRight || horizontal < 0 && facingRight)
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = *theScale*
Comment