Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Editor tool to snap a unit to a node via unit inspector

Discussion in 'Scripting' started by Crossbreed, Sep 3, 2020.

  1. Crossbreed

    Crossbreed

    Joined:
    Jul 5, 2016
    Posts:
    10
    Hello!

    I am trying to make a tool for a package I am making. I would like the Unit to have a button in the inspector that snaps him to a specific node. I would like to do this simply by selecting the node after the button press, or dragging the Unit over the node, etc.

    I cant figure out a way to get the unit to snap to a selected node. Entering in the node coordinates isnt helpful as those arent visible without a flag and I dont want to require that. I want a clean, easy way to say "I want this unit to go to this node, and I want that node to recognize that this unit is occupying it." via a button in the inspector.

    I have all of the code working except for the button. I can easily have it grab the first open node, but selecting a node within the scene in a user friendly way just seems difficult. I dont see a "nextSelection" option or anything, and I cant select a node and a unit and have the unit inspector appear.

    If I cant do it through the Unit inspector I could build another tool that opens in a window and lets you select a unit and a node, but this feels overly clunky.

    Help is very much appreciated in this matter. Thank you!