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

Chess-like board game - best approach to highlight board tiles

Discussion in 'Scripting' started by eco_bach, Sep 20, 2017.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Hi.
    Creating a chess-like board game in which game pieces occupy more than 1 square. When a user drags a game piece I want the board tiles or squares to highlight or otherwise change appearance even when the game piece is partially over them. What would be the best approach for this? Use Raycasting or...?
     
  2. laxbrookes

    laxbrookes

    Joined:
    Jan 9, 2015
    Posts:
    235
  3. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    hmmm. thanks will research that method further but don't think its what I need.

    I think I need to rephrase my question to ' How to determine when a game object is partially occluded?'
     
  4. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    You could use triggers. If a game piece enters a trigger, highlight that one until it exits.
     
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I would not use raycasting or occlusion for this. Just use math. If it's a chess-like board game, your board is a grid, so the math for calculating which squares are touched by a figure at a given position is pretty simple.
     
  6. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    I agree, the only reason I suggested triggers was for the case where his pieces were irregularly shaped which could make the math complicated for accurate overlap detection.
     
    JoeStrout likes this.