- Home /
Too subjective and argumentative; not enough information given
How to implement a board game movement.
Ok, so in this image i am trying to create a "boardgame" i am wondering if i can move say, 5 to the right, left, etc.
Can anyone Help?
Thanks in advance!
Answer by KevLoughrey · Apr 30, 2014 at 10:26 PM
The easiest way to do it would be to picture the board as a grid (15 by 15 in this case), with each dot in its own grid tile. Then if you want to move 5 to the right, you increment the x position by the width of a grid tile multiplied by 5.
How exactly would I achieve this, would I be using the transform.translate ?
transform.position = new Vector3(transform.position.x + 3 * tilewidth, transform.position.y, transform.position.z)
ok with this, i have
if (diceNumber == 1) {transform.position = new Vector3(transform.position.x + 1 * popDistance, transform.position.y, transform.position.z);}
but when i roll a "1" it continuously goes forward.
is there a snippet that makes the code run only once?
Thanks anyway!
Answer by Jeff-Kesselman · Apr 30, 2014 at 10:49 PM
The question is, do you want to pop directly there or slide there? If you want to pop then the answer above is correct.
If you want to slide, then you set a velocity to the right and check on update if you are within a "fudge distance" that is about equal to your move per frame. If so then you set the velocity back to zero and then set your position in your tsrnaform as described above.
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Finding Edges 1 Answer
how can i set up a wall detection to enable down movement? 2 Answers
Bringing a GUI window to the front 1 Answer
Screetching Sound While Walking? Why? 0 Answers