Question by
luis097 · Jun 01, 2016 at 09:07 PM ·
character movement
Why doesn't my character move?
I've been following a tutorial on how to make a 2D character control, and wrote exactly what it had on my script. I'm using Microsoft Visual Studio to script C Sharp. I don't know what the problem is, there's no error and yet it doesn't work. Looked through every lines and they are as identical as the one from the tutorial. I was wondering if there's something wrong with my script? If so, please explain what I can do to make it work. Here's the script.
using UnityEngine; using System.Collections;
public class playerController : MonoBehaviour {
//movement variables
public float maxSpeed;
Rigidbody2D myRB;
Animator myAnim;
// Use this for initialization
void Start () {
myRB = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();
}
// Update is called once per frame
void FixedUpdate () {
float move = Input.GetAxis("Horizontal");
myRB.velocity = new Vector2(move * maxSpeed, myRB.velocity.y);
}
}
Comment
Your answer