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 /
  • Help Room /
avatar image
0
Question by LaskioGaming · Nov 04, 2016 at 05:51 AM · c#

All of a sudden Shift + A D stopped working

Out of nowhere Shift + A + D wont move my character, A or D by itself with shift will, and Shift + W A or S will work, Only A and D combined and also Up and Left combined. It worked earlier and I kept swapping stuff out in my code and cannot find anything that I changed as a problem. If anyone can help it would be greatly appreciated. Sorry for the messy code.

 public class PlayerController : MonoBehaviour
 {
 
     public float moveSpeed;
 
     private Animator anim;
 
     private bool playerMoving;
 
     private Vector2 lastMove;
 
     private bool superSaiyan;
 
     private bool spellCooldown;
 
     public float playerDamage = 10f;
 
     private bool spellDurationOn;
 
     private Vector2 lastMoveSuper;
 
     private bool isSprinting;
 
     //private Vector2 lastMoveSprint;
 
     private Rigidbody2D myRigidBody;
 
    
 
     
 
     void Start()
     {
         anim = GetComponent<Animator>();
         myRigidBody = GetComponent<Rigidbody2D>();
     }
 
     
 
 
     // Update is called once per frame
     void Update() {
 
       
 
 
 
         if (spellDurationOn == true)
         {
 
             playerDamage = 10f * 3;
         }
 
         if (spellDurationOn == false)
         {
 
             playerDamage = 10f;
         }
         
        
 
 
         playerMoving = false;
         {
             if (Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5f)
             {
                 //Move Right
                //transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
                 myRigidBody.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * moveSpeed, myRigidBody.velocity.y);
                 playerMoving = true;
                 lastMove = new Vector2(Input.GetAxisRaw("Horizontal"), 0f);
                 lastMoveSuper = new Vector2(Input.GetAxisRaw("Horizontal"), 0f);
                 //lastMoveSprint = 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));
                 myRigidBody.velocity = new Vector2(myRigidBody.velocity.x, Input.GetAxisRaw("Vertical") * moveSpeed);
                 playerMoving = true;
                 lastMove = new Vector2(0f, Input.GetAxisRaw("Vertical"));
                 lastMoveSuper = new Vector2(0f, Input.GetAxisRaw("Vertical"));
                 //lastMoveSprint = new Vector2(0f, Input.GetAxisRaw("Vertical"));
             }
 
         }
 
         /*isSprinting = false;
         if (playerMoving == true)
         {
             
             if (Input.GetAxisRaw("Fire3") > 0.5f)   unneccesary
             {
                 isSprinting = true;
             }
           }
           */
 
 
         if (Input.GetAxisRaw("Horizontal") < 0.5f && Input.GetAxisRaw("Horizontal") > -0.5f)
             //if (Input.GetAxisRaw("Horizontal") > 0.5 && Input.GetAxisRaw("Horizontal") < -0.5)  if i want to ice skate
             {
             myRigidBody.velocity = new Vector2 (0f, myRigidBody.velocity.y);
         }
 
         if (Input.GetAxisRaw("Vertical") < 0.5f && Input.GetAxisRaw("Vertical") > -0.5f)
        // if (Input.GetAxisRaw("Vertical") > 0.5 && Input.GetAxisRaw("Vertical") < -0.5)  ice skate
         {
             myRigidBody.velocity = new Vector2 (myRigidBody.velocity.x, 0f);
         }
         
         //Animation Parameters            
         anim.SetFloat("MoveX", Input.GetAxisRaw("Horizontal"));
         anim.SetFloat("MoveY", Input.GetAxisRaw("Vertical"));
         anim.SetBool("PlayerMoving", playerMoving);
         anim.SetBool("SuperSaiyan", superSaiyan);
         anim.SetBool("SpellCooldown", spellCooldown);
         anim.SetBool("SpellDurationOn", spellDurationOn);
         anim.SetFloat("LastMoveX", lastMove.x);
         anim.SetFloat("LastMoveY", lastMove.y);
         anim.SetFloat("LastMoveSuperX", lastMoveSuper.x);
         anim.SetFloat("LastMoveSuperY", lastMoveSuper.y);
         //anim.SetFloat("LastMoveSprintX", lastMoveSprint.x);
         //anim.SetFloat("LastMoveSprintY", lastMoveSprint.y);
         //anim.SetFloat("LastMoveSprintX", lastMoveSuper.x);
         //anim.SetFloat("LastMoveSprintY", lastMoveSuper.y);
         anim.SetBool("IsSprinting", isSprinting);
     }
 //Need to add Damage when Super Saiyan is Active
     void OnGUI()
     {
 
         if (spellDurationOn == false)
         {
             if (Input.GetAxisRaw("Fire3") > 0.5f)
             {
                 //isSprinting = true;
                 StartCoroutine(SprintMode());
             }
         }      
 
 
 
         if ( isSprinting == false && spellCooldown == false)
         {
             if (Input.GetAxisRaw("Fire2") > 0.5f)
             {
                 StartCoroutine(SuperSaiyanMode());
 
             }
         }
     }
 
 
 
 
     public IEnumerator SprintMode()
     {
 
         
         moveSpeed = 8;
         yield return new WaitForSeconds(0f);
         moveSpeed = 5;
 
         
 
 
     }
 
 
 
 public IEnumerator SuperSaiyanMode()
 {
         moveSpeed = 0;
         superSaiyan = true;
            
     yield return new WaitForSeconds(1.5f);
        moveSpeed = 5;
        spellDurationOn = true;
     superSaiyan = false;
     spellCooldown = true;
     
     yield return new WaitForSeconds(5f);
     spellDurationOn = false;
     yield return new WaitForSeconds(30f);
     spellCooldown = false;
         
        
 
 }
 
 
 }
 

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

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

251 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 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 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

UI button that displays on top of a clickable 2D Box Collider in the scene won't work 0 Answers

Gameobject spinning by itself. 2 Answers

Is there a way to make a script activate when you look at an object? 1 Answer

Blank Console Error on Empty Project with a Single C# Script 7 Answers

Animation clip only plays once when button is pressed, and then will not play again 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