full screen background image
RSS
Follow by Email
Facebook
Facebook
Google+
http://gamerplays.com/unity-strategy-games-12-mouse-selection-script-complete/">
Twitter
Share

Unity Strategy Games [12] – Mouse Selection Script Complete



In this video I complete the mouse selection script. Users can click or drag to manage selection, as well as hold the shift key to manage groups of units in the …

source

Please follow and like us:



5 thoughts on “Unity Strategy Games [12] – Mouse Selection Script Complete

  1. Master Muke

    I noticed a bug when drag selecting off of the ground, meaning when you
    start a drag and continue until the mouse is no longer over the terrain
    (plane in my case). The box stops ‘growing’ and remains with the mouse
    until you click again somewhere on the ground/game unit. Not sure if this
    was already covered (I may have missed it!). Thanks for any help you can
    offer.
    Great tutorials BTW!

    Reply
  2. Michal Krzych

    I have found a couple of bugs in the Update() method. Down in the section

    // if shift IS down and object is selected, deselect it
    GameObject selectedObj =
    hit.collider.transform.FindChild(“Selected”).gameObject;
    selectedObj.SetActive(selectedObj.activeSelf ? false : true);

    Reply
  3. UnityChat

    Hello, I haven’t got this far into the series yet! You are away ahead of me
    haha. I would instantiate Units in the world and not parent them to
    anything. And test the units in the drag based on how many Unit layer
    objects on currently on the screen.

    Reply
  4. 222ableVelo

    Any chance you could do a tutorial on how to drag select units based on a
    bounding box that has been converted to screen space? And especially, how
    to account for camera perspective (i.e. if the main camera is at say a 45
    degree angle), as most rts’s use a perspective camera with a slight
    rotation. I’m having the hardest time accounting for the camera
    perspective. So if a unit is on the very right side of the screen, the
    WorldToScreenPoint position is off-center (to the left) of the unit.

    Reply
  5. Master Muke

    Sorry to bother you again, but I think originally we had an empty game
    object holding the ‘Unit’ object as a child in order to get it to position
    correctly. I’m adding units via the right mouse button but then I get a
    null reference when trying to drag select units. I think the problem is
    with the ‘Unit’ hierarchy. Have you already tried to dynamically add units
    that can be selected and if so, what problems might I be facing? Big thanks
    in advance again for any help you can offer.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *