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
  4. Dismiss Notice

How can I make my "asteroids" move in certain direction

Discussion in '2D' started by Dervi98, Jan 16, 2021.

  1. Dervi98

    Dervi98

    Joined:
    Jan 6, 2021
    Posts:
    5
    Hello, im making my very first game on Unity in 2D. How can i make asteroids move in a certain direction? (Towards earth). Im very new in coding and i use mostly tutorials to make my game and learn from them.
    (White Squares are the "asteroids")
    Screenshot_1.png
     
  2. Dervi98

    Dervi98

    Joined:
    Jan 6, 2021
    Posts:
    5
    Also how can i add two names into one bracket? i want to add Player as well and i know that the solution is prob. simple but i really forgot how to do that
    if (something.gameObject.name == "Earth" + "Player")

    //Edit: I somehow managed it to not add the Player in brackets but just create same line of code and i replaced the earth with player so now i have both in one script
     
    Last edited: Jan 16, 2021