Question by 
               Master356 · Apr 12, 2016 at 05:41 PM · 
                scripting problemcollisionbugcollision detectioncollisions  
              
 
              How i can fix a player controller bug?
When i walk, if i meet a block and i go in it, the player will be bugged in the block..... Someone can help me?
This is the player script (with the animations):
pragma strict
var jump :boolean = true; var jumpspeed : int = 15; var jumptimer :float = 0; var speed : int = 8; var anim : Animator;
function Start () {
}
function Update () {
 if (Input.GetKey (KeyCode.A)) 
     {
         transform.localScale.x = -5;
         transform.Translate(Vector3(-speed,0,0) * Time.deltaTime);
         anim.SetBool("Walk",true);
     }
 if (Input.GetKey (KeyCode.D)) 
     {
         transform.localScale.x = 5;
         transform.Translate(Vector3(speed,0,0) * Time.deltaTime);
         anim.SetBool("Walk",true);
     }
 if (Input.GetKeyUp (KeyCode.A)) 
     {
         transform.localScale.x = -5;
         anim.SetBool("Walk",false);
     }
 if (Input.GetKeyUp (KeyCode.D)) 
     {
         transform.localScale.x = 5;
         anim.SetBool("Walk",false);
     }
 if (Input.GetKey (KeyCode.Space))  
     {
         if (jump == true) {
             GetComponent.<Rigidbody2D>().velocity.y = jumpspeed;
             jump = false;
             anim.SetBool("Jump",true);
     }
 }
 
               }
function OnCollisionEnter2D (other: Collision2D) {
 {
 if(other.gameObject.tag == "Ground") {
     jump = true;
     anim.SetBool("Jump",false);
     }
 }
 {
 Debug.Log("collision");
 }
 
               }
               Comment
              
 
               
              Your answer