Search Unity

Set rotation on a GameObject

Discussion in '2D' started by Deleted User, Nov 12, 2019.

  1. Deleted User

    Deleted User

    Guest

    Good morning, everyone!
    I'm new to this world of Unity and as a result I'm learning the basics

    Here is my problem that I think is simple to solve :D

    Code (CSharp):
    1.     private void OnCollisionEnter2D(Collision2D collision2D)
    2.     {
    3.         if (!collision2D.gameObject.name.Equals("Plafond"))
    4.         {
    5.             rb2d.velocity = Vector2.zero;
    6.             isDead = true;
    7.             //Joue l'animation "Die"
    8.             anim.SetTrigger("Die");
    9.             //On appelle notre GameControl, la fonction de la mort
    10.             GameControl.instance.BirdDie();
    11.         }
    12.         else
    13.         {
    14.             bird.transform.eulerAngles.Set(0, 0, 0);
    15.         }
    16.     }
    In fact, in the else, I would like "bird" to have a rotation of 0 on the Z axis, so that it can be straight.

    Is that possible? The code I made doesn't work

    Thank you!
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    When you say doesn't work, what does it mean? What happens?
    Is else even called?

    Put Debug.Log there and check.
    Or use BreakPoints in VS for debugging, to go step by step.
     
  3. Deleted User

    Deleted User

    Guest

    The rotation does not take place, whether I remove or reset the code nothing changes :(
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Is else condition called?
     
  5. Deleted User

    Deleted User

    Guest

    Yes, I see-it in the console but I think I found out why it doesn't work, I have to put it in my Update function