I am following the character controllers tutorial by unity, I cant seem to get this to work.
I have checked 3 times now and I cant find out what’s wrong.
using UnityEngine;
using System.Collections;
public class playerController : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate ()
{
float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, 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 camera is not attached to the character btw.
Thanks for any help I get!