Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Aug 13, 2018 at 01:23 PM by pgk_007 for the following reason:

Issue resolved

avatar image
0
Question by pgk_007 · Aug 12, 2018 at 02:18 PM · 2d gamemovement script

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can i normalize 2d Vectors? 2 Answers

How to make the sprite move a certain amount of pixels when a key is pressed? 1 Answer

How can I limit my 2D player movement along the Y-axis? 1 Answer

How to animate car movement without player input \ 2D TOP DOWN GAME 1 Answer

Player controller jump not always working 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges