Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity import manager not working properly

Discussion in 'Editor & General Support' started by Lexo18, Apr 29, 2015.

  1. Lexo18

    Lexo18

    Joined:
    May 12, 2013
    Posts:
    34
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerMovement : MonoBehaviour {
    5.     //public variables
    6.     public float acceleration = 5;
    7.     public float decceleration = .2f;
    8.     public float gravity = 21;
    9.     public float airAcceleration = 2.5f;
    10.     public float jumpAllowTime = .1f;
    11.     public float wallJump = 10;
    12.  
    13.     //Private variables
    14.     float curSpeed;
    15.     float jumpAllowTrack;
    16.     float moveSmooth;
    17.     CharacterController cont;
    18.     bool run = false;
    19.     Vector3 curMove;
    20.  
    21.     //Smoothdamp variables
    22.     float walkMoveV;
    23.     float runMoveV;
    24.     float stopMoveV;
    25.     float airAccelerationV;
    26.     private Stats Player;
    27.  
    28.     //Get that stats
    29.     void Awake (){
    30.         Player = GetComponent<Stats>();
    31.     }
    32.     // Use this for initialization
    33.     void Start () {
    34.         cont = GetComponent<CharacterController>();
    35.     }
    36.  
    37.     // Update is called once per frame
    38.     void Update () {
    39.         //sprint and movement.
    40.         if(Input.GetKey (KeyCode.A) || Input.GetKey (KeyCode.D))
    41.             run = true;
    42.         else  
    43.             if(run == true && Input.GetKey (KeyCode.LeftShift))
    44.                 curSpeed = Mathf.SmoothDamp(curSpeed, Input.GetAxisRaw ("Horizontal") * Player.runSpeed, ref runMoveV, moveSmooth);
    45.      
    46.         else if (run == true)
    47.             curSpeed = Mathf.SmoothDamp (curSpeed, Input.GetAxisRaw ("Horizontal") * Player.speed, ref walkMoveV , moveSmooth);
    48.      
    49.         else
    50.             curSpeed = Mathf.SmoothDamp (curSpeed, 0, ref stopMoveV , moveSmooth);
    51.      
    52.      
    53.         if(Input.GetButtonDown ("Jump") && jumpAllowTrack >= 0)
    54.             curMove.y = Player.jump;
    55.      
    56.         // the actual movement
    57.         cont.Move(curMove*Time.deltaTime);  
    58.      
    59.         curMove = new Vector3(curSpeed, curMove.y, 0);
    60.         //Is it grounded?
    61.         if(cont.isGrounded){
    62.             //reset vertical movement
    63.             curMove.y=0;
    64.             // normal control
    65.             moveSmooth = acceleration;  
    66.             jumpAllowTrack = jumpAllowTime;  
    67.         }
    68.      
    69.         if(!cont.isGrounded){
    70.             // enable the gravity
    71.             curMove -= new Vector3(0, gravity * Time.deltaTime, 0);
    72.             //give less control in the air
    73.             moveSmooth = airAcceleration;
    74.             jumpAllowTrack -= Time.deltaTime;
    75.         }  
    76.     }
    77. }
    I have this code which has no errors and works just how I want it to, I reset the input manager so that it has all of the default settings, I've tried making a new input axis and no matter what the W and A keys do not work and I have to wait a few seconds before the left and right keys start working and i know it is not my keyboard because typing for everything works perfectly fine.
     
  2. Lexo18

    Lexo18

    Joined:
    May 12, 2013
    Posts:
    34
    Nevermind fixed it by restarting the file.