- Home /
 
Problem with collider in Unity 2D...
Hi, I have problem with physics 2D in Unity I'm making a game like rpg, and my cotroller script don't work Here it is: using UnityEngine; using System.Collections;
 public class controller : MonoBehaviour {
     public int Health;
     public string idle;
     public string Walkdown;
     public string Walkup;
     public string Walkleft;
     public string WalkRight;
     public enum State{Idle, WalkLeft, Walkright,WalkUp,WalkDown, die, attack};
     public State st;
     public float k;
     
     // Update is called once per frame
     void Update () {
         if(Input.GetKey(KeyCode.W))
         {
             rigidbody2D.velocity = transform.up * k;
             st = State.WalkUp;
 
 
         }
         if(Input.GetKeyUp(KeyCode.W))
         {
 
             st = State.Idle;
         }
         if(Input.GetKey(KeyCode.S))
         {
             rigidbody2D.velocity = -transform.up * k;
             st = State.WalkDown;
         }
         if(Input.GetKeyUp(KeyCode.S))
         {
             st = State.Idle;
         }
         
         if(Input.GetKey(KeyCode.A))
         {
             rigidbody2D.velocity = -transform.right * k;
             st = State.WalkLeft;
         }
         if(Input.GetKeyUp(KeyCode.A))
         {
             st = State.Idle;
         }
         if(Input.GetKey(KeyCode.D))
         {
             rigidbody2D.velocity = transform.right* k;
             st = State.Idle;
         }
         if(Input.GetKeyUp(KeyCode.D))
         {
             st = State.Idle;
         }
 
             
         if(st == State.WalkDown){
             animation.Play("walk_down.anim");
 
         }
         if(st == State.WalkUp)
         {
 
             animation.Play("walk_up.anim");
         }
         if(st == State.WalkLeft){
 
             animation.Play ("walk_left.anim");
         }
         if(st == State.Walkright){
             animation.Play ("walk_right.anim");
         }
         else if(st == State.Idle){
             animation.Play ("idle.anim");
         }
     }
 }
 
               My character ignores physics Like that: 
Please help me Character has got rigidbody 2D and Collider2D(Box)
 
                 
                problem1.png 
                (64.1 kB) 
               
 
              
               Comment
              
 
               
              Your answer