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

2 questions that pretain to a tower defense game

Discussion in 'Scripting' started by InsensitveJ0ker, May 5, 2020.

  1. InsensitveJ0ker

    InsensitveJ0ker

    Joined:
    Feb 1, 2019
    Posts:
    20
    The first is how would you have range for one object to detect other objects and then target the nearest object. The second question is how do you have an object point in the direction it's moving.
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I think the first question for you should be where is the tutorial section, you won't be able to do a game if you need to ask questions like this.

    To answer your questions:
    To have range you can either do an overlap sphere to get whatever colliders are in range of X or you can look up a list of all targetable thinks and sift though them with variables such as range.

    To get the rotation you do vector math.

    If you just wanna do it there's a short 1-hour "tutorial" by 'quill18creates' and a series by 'brackeys', look it up on youtube.
     
  3. InsensitveJ0ker

    InsensitveJ0ker

    Joined:
    Feb 1, 2019
    Posts:
    20
    Ay thanks man