Hey Guys,
I have a basic script going for my character however I am unable to manipulate the rigidbody’s velocity. The player flips and faces the right way, but he stays in the same place.Here is my code:
using UnityEngine;
using System.Collections;
public class playerController : MonoBehaviour {
private Animator playerAnim;
private Rigidbody2D playerBody;
public float maxSpeed;
bool grounded;
bool isFacingRight;
// Use this for initialization
void Start () {
grounded = true;
playerBody = GetComponent ();
playerAnim = GetComponent();
}
// Update is called once per frame
void Update () {
float moveInp = Input.GetAxis(“Horizontal”);
playerBody.velocity = new Vector2 (moveInp * maxSpeed, playerBody.velocity.y);
if (moveInp > 0) {
gameObject.transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));
isFacingRight = true;
} else if (moveInp < 0) {
gameObject.transform.rotation = Quaternion.Euler (new Vector3 (0, 180, 0));
isFacingRight = false;
}
}
}