- Home /
 
               Question by 
               Brithingr · Mar 27, 2018 at 09:51 AM · 
                2dscripting problemanimatorif-statements  
              
 
              What if-statement to choose and how to involve. 2D
I had already tried to check if coordinates are reached, if colliders are attached. but my animation don't want to change. I'm pretty sure that smth wrong with transform.position and if statement in update method. Fall animation looped in time and pose and no exit time. 
     public Vector2 position0 = new Vector2(-12, 6);
     public Vector2 position1 = new Vector2(-7.5f, -2.1f);
     public GameObject Char;
     public GameObject Buff;
     
     private Animator anim;
     private bool Landed;
 
     // Use this for initialization
     void Start()
     {
         anim = GetComponent<Animator>();
         Landed = false;
     }
 
     void OnCollisionEnter2D(Collider2D other) {
         if (other.gameObject.name == "Sprite Sheet 01_2"
             /*GetComponent<CircleCollider2D>().gameObject.name == "Sprite Sheet 01_2"*/)
         {
             //anim.Play("Landed", -1, 0f);
             //anim.SetBool("Landed", true);
             Landed = true;
         }
         else
         {
             Landed = false;
         }
     }
 
     // Update is called once per frame
     void Update ()
     {
         /* transform.position = Vector2.MoveTowards(new Vector2(transform.position.x, transform.position.y), position1, 3
  * Time.deltaTime);*/
         // if (gameObject.GetComponent<CircleCollider2D>().)
 
             //------stop the moveTowards //activte camerafollow script and char - visible
             if (transform.position.x > -7.49f && transform.position.y < -2f)
         {
             GetComponent<SpriteRenderer>().enabled = false;
             Char.GetComponent<SpriteRenderer>().enabled = true;
             Buff.SetActive(true);
             Camera.main.gameObject.GetComponent<Camera2DFollow>().enabled = true;
         }
         else
         {
 
         }
     }
     void DestroyGameObject() {
         Destroy(gameObject);
     }
 
                 
                unintyquestions.jpg 
                (209.5 kB) 
               
 
              
               Comment
              
 
               
              Fixed Duration and apparently non-interruptable? Add debug.log to your Collisions routine to see if its firing.
so should i turn off duration? and put smth in interruption? these options were as default. I gave all my platforms tag - Platform and changed if statement in OnCollisionEnter2D to other.gameObject.tag == "Platform". and add debug.log 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                