Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

need advice on floor tile build (Solved)

Discussion in 'Scripting' started by Andreas88, Oct 21, 2016.

  1. Andreas88

    Andreas88

    Joined:
    Dec 22, 2015
    Posts:
    67
    Hi there. i have been working on a RTS/Sim game for quite some time now. and recently i thought i would implement a new feature but it´s a bit more difficult than i had anticipated. anyway...

    in my game, before i can build anything i need to build a floor tile. which is an simple gameobject, but i am beginning to find it tedious to simply point and click every time i need a floor tile. so my solution is to be able to click and drag out multiple tiles in the x axis and in the z axis.

    my initial idea was to create a dynamic array or list of transforms and instantiate my ghosted floor tiles at the same time. and finally when i click again the ghosted floor tiles are being replaced by the real floor tiles.

    i am not asking for any code but i need some advice on how this could be done. i have been trying google these things but i have no idea what i am actually searching for. i have seen this type of game mechanic in other games but have no idea how this is done.
    hope someone would be kind enough to help me out :)
    thanks
     
  2. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    291
    If you want to display ghost tiles dynamically then a list or array (you would need a maximum size there so you can avoid resizing the array) would be my way to reference the tiles.

    But for the sake performance, I would not instantiate/destroy the tiles on the fly, but store a pool of tiles somewhere in the scene and retrieve them as needed.
     
  3. Kalladystine

    Kalladystine

    Joined:
    Jan 12, 2015
    Posts:
    227
    Check Project Corcupine (also Quill18's channel on youtube), they have this functionality and the project is open sourced. I haven't checked how they've done it, but it works there, so should be able to at least hint you in the right direction.
     
  4. Andreas88

    Andreas88

    Joined:
    Dec 22, 2015
    Posts:
    67
    thank you so much guys :)
    now i got some to work with.