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

Checkers game programming question

Discussion in 'Scripting' started by JEulerium, Mar 5, 2015.

  1. JEulerium

    JEulerium

    Joined:
    Feb 18, 2014
    Posts:
    35
    Hi! I'm working on some variation of checkers game... and I have question about how to organize the interaction between game logic and gameobject visualization. Let me explain.

    To calculate the moves on checkers I want to use some logic structure, not to work with the gameobject directly. It can be called as abstract machine for checkers calculation, to analyse the state of the board and so on, to choose the best available move.

    How I should handle this better way? Use the gameobject (checkers) directly or create some logical structure and then map the logical stuff into real one? How to do it better?
     
  2. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Use 2d arrays to store the board and do calculations on that.
     
  3. JEulerium

    JEulerium

    Joined:
    Feb 18, 2014
    Posts:
    35
    So, I use it for my calculation and then call something like "ApplyMovement" and my game is actually moving the gameobjects? And if I actually move gameobject (player move) it is adding that information to the board state?
     
  4. honprovet

    honprovet

    Joined:
    Mar 4, 2014
    Posts:
    23
    To move the ganeobjects you must manipulate their transform conponent.

    Lets say that a Vector3 nextPosition has the position where that GameObject must go.

    Then in the code that is a component of the GameObject you do: gameobject.transform.position=nextPosition.

    Google these:

    Transform.position,
    Transform.translate,
    Vector3. Lerp,
    Unity components,
    Unity gameobjects.

    Seem to me like you are missing the basics. The gameobjects wont magically move just because you have a chess code in the background.

    Hope i could help.
     
  5. JEulerium

    JEulerium

    Joined:
    Feb 18, 2014
    Posts:
    35
    Okay. :) Thank you!