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

What to use as position objects for a sprite to move to?

Discussion in 'Getting Started' started by LilGames, Feb 7, 2017.

  1. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    527
    What do people like to use for VISUALLY setting multiple destination "targets" that a sprite can move to? Here's what I mean:

    Let's say you have a sprite and you'd like to have 5 positions on the screen that the sprite could move to. Instead of keeping an array of coordinates, I'd like to use objects that I can see in the editor but not see in the game. The reason for this is it makes it easy for a designer to just move the objects and that changes where the sprite can move to. No recording/entering in of coordinate values is necessary this way.

    I was thinking of using empty GameObjects but they are invisible if they are not selected. I was wondering what experienced people tend to use. A box? Or perhaps there is "helper" class of objects in Unity that I am overlooking?

    I've looked into the Navigation options but they seem specific for 3D characters and way point systems.

    Thank you for your input.
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    Gizmos. They are only visible from within the editor but the GameObject will remain.

    https://docs.unity3d.com/ScriptReference/Gizmos.html

    Edit: Updated to make it less confusing.
     
    Last edited: Feb 16, 2017
    SarfaraazAlladin, Kiwasi and LilGames like this.
  3. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    527
    thanks but gizmos cannot be created and used as gameobjects.

    I'm looking for best-practices for setting up target location that a sprite can move to.
     
    Last edited: Feb 7, 2017
  4. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Add a sprite for every 'target' you need. Don't texture, but color to a contrasting color to your scene. The default white should work in most cases.

    Place all targets where you want them in the scene and test in your scene.

    If your satisfied with target locations, simply turn the alpha for each sprite to transparent.
     
    LilGames likes this.
  5. LilGames

    LilGames

    Joined:
    Mar 30, 2015
    Posts:
    527
    Last edited: Feb 15, 2017
  6. smacbride

    smacbride

    Joined:
    Jan 10, 2015
    Posts:
    50
    The Adventure tutorial goes over this as well.
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I would suggest using a GameObject with a gizmo on it instead of a Sprite. Gizmos will acrobatically be pulled out of your build. Sprites will not, and may cause issues down the line.
     
    LilGames and Ryiah like this.
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    Just read my post again and realized the wording was awful. Gizmos are only visible from within the editor but the object the script is attached to will remain in the scene. I'll update my post to clarify that.
     
  9. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,999
    i usually use empty gameobject with icon assigned (from that inspector dropdown),
    and combine with editor script to draw gizmo lines between children of "TargetsFolder"
    (so can see line going from target 1-2-3-4...)
    upload_2017-2-16_15-37-25.png
     
    Last edited: Feb 16, 2017