Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

"There are inconsistent line endings in the 'Assets/Scripts/PlayerMovement.cs. Some are Mac OS X (UNIX) and some are Win

"There are inconsistent line endings in the 'Assets/Scripts/PlayerMovement.cs' script. Some are Mac OS X (UNIX) and some are Windows. This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands. "

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class PlayerMovement : MonoBehaviour {

private Animator playerAnimator;
private float moveHorizontal;
private float moveVertical;
private Vector3 movement;


// Use this for initialization
void Start () {
    playerAnimator = GetComponent<Animator> ();

}

// Update is called once per frame
void Update () {
    moveHorizontal = Input.GetAxisRaw("Horizontal");
    moveVertical = Input.GetAxisRaw("Vertical");

    movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);


}

void FixedUpdate () {
    if (movement != Vector3.zero) {
        playerAnimator.SetFloat("Speed", 3f);
    } else {
        playerAnimator.SetFloat("Speed", 0f);
    }


}

}

2 Answers

Randy Eichelberger
Randy Eichelberger
445 Points

http://www.grebulon.com/software/stripem.php#download

Edit: So this is caused because Unix and Windows and Mac all have different ways they end lines. This addon fixes that for you in Visual Studio. I installed it and opened VS up and it had a popup that let me easily fix it.

If I am in Windows, so I selected "convert all end lines to Windows"

Daniel Black
Daniel Black
5,017 Points

I don't know if this helps; but, I had this same issue. I'm using Visual Studio 2017 along side Unity (2017.1.1f1 Personal) rather than the editor used in the video. After seeing the error in Unity and not being able to click the "run" button, I hit "debug" in Visual Studio. Eventually, a "solution" window popped up feeding me the same error description that Unity gave. It then gave me the option to standardize the line endings to any given platform. I chose Windows, and was then able to "run" the program in Unity. While this worked for my platform (Windows 10 Creator), I'm guessing that this isn't the best solution in a real world sample that you would like to port to any other platforms.