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

This will be a dumb question.

Discussion in 'Scripting' started by yaIi, Oct 18, 2015.

  1. yaIi

    yaIi

    Joined:
    Jun 8, 2015
    Posts:
    7
    How can i use 2 things that have to be so something happens?
    Code (CSharp):
    1.     public void OnTriggerEnter2D(Collider2D collisionObject)
    2.     {
    3.         Debug.Log("Trigger Hit");
    4.         if (collisionObject.gameObject.tag == "h" and Input.GetKey(KeyCode.W))
    5.         {
    6.             transform.Translate(Vector2.up * jumpspeed * Time.deltaTime);
    7.         }
    8.     }
    :D
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    &&

    Code (csharp):
    1. if(this && that) {  }
     
  3. Skyous

    Skyous

    Joined:
    Oct 18, 2015
    Posts:
    4
    Just like '==' means is equal too, you can use '&&' to mean and.