- Home /
Moving character to points along a board - c#
Hey guys,
I'm making a monopoly style board game where a player can move along a board.
The way I'm doing it right now is that I have a bunch of cubes that I get into an array and the character just lerps from one cube to another down the array.
The problem i'm having is that I don't want every character to not go to the exact same spot because if they do you can't see multiple character on the same cube. I tried setting up a rigid body on the character and then getting the distance between the player and the cube and if the player gets within a certain distance then stop. This doesn't work because my character get the point and then start jittering/or knocking the other character off the cube area.
Any ideas on how I can do this better?
Thanks! Chris
Try an XOffSet value and apply it cumulatively for every player in a square to position them somewhat differently.
Answer by gajdot · Nov 15, 2013 at 10:42 AM
Add a parent empty gameobject for you characters and add some offset for you character with position to the parent empty gameobject. Then just move your parrent gameobject to the cube positions. This way when they are on the same cube even if the parrent empty gameobject is in the same place the caracters have an offset to each other, so they are all visible.
Answer by tetryon · Dec 18, 2013 at 11:08 PM
I've only been using Unity for 12 days, so take this with a pinch of salt....!
I am doing similar to you, but have opted for a one-way linked-list style of doing the cubes.
For the offsite, I have a total of four players. I've selected positions on the tile for each using offsets. Each player object stores that offsite as a number (x and z). A switch (name) call in the Awake() sets those numbers once, and they are used in the Update() by the Lerp() call. I added a RigidBody to the player object, removed gravity and made it a Kinematic. It then uses triggers to know when it hits a tile. So it passes through each tile, slowing down a little as it gets to each one. I also reduced the scale of the collider box for the tiles (using a Prefab).