- Home /
Issue resolved
Player Character No Longer Moving
Hi, so I've been following this tutorial (https://www.youtube.com/watch?v=Pk3GCgaNVTY&list=PLiyfvmtjWC_X6e0EYLPczO9tNCkm2dzkm∈dex=1) to make a 2D RPG game. I had been working on my MacBook Air so far until I had to move it onto my Windows 10 PC so I could get the maps on it, also it is just more convenient for me. Ever since, I've been unable to actually get my character to move when I go into play, like he used to move but he straight up doesn't move anymore, where before he moved fine. I can't figure out what's keeping him from being able to move and it's really bugging me at this point. Does it have something to do with me moving from Mac to PC? Part of me thinks it's my keyboard, if that's even possible since I can't backspace when I'm renaming something and I can't ctrl + z with shortcuts. I know I didn't enter anything wrong when I was coding it, because like I said, it worked fine before. This is the code I used to make him move. Any help is much appreciated!
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float moveSpeed;
private Animator anim;
private bool priestMoving;
private Vector2 lastMove;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
priestMoving = false;
if(Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f )
{
transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
priestMoving = true;
lastMove = new Vector2 (Input.GetAxisRaw ("Horizontal"), 0f);
}
if(Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f )
{
transform.Translate (new Vector3(0f, Input.GetAxisRaw("Vertical") * moveSpeed * Time.deltaTime, 0f));
priestMoving = true;
lastMove = new Vector2 (0f, Input.GetAxisRaw ("Vertical"));
}
anim.SetFloat ("MoveX", Input.GetAxisRaw ("Horizontal"));
anim.SetFloat ("MoveY", Input.GetAxisRaw ("Vertical"));
anim.SetBool ("PriestMoving", priestMoving);
anim.SetFloat ("LastMoveX", lastMove.x);
anim.SetFloat ("LastMoveY", lastMove.y);
}
EDIT: Well it solved itself by asking if I wanted to change the line endings on the rewritten code even though it was new from this PC and it already asked on the old set of code.