What does then transform.position do how do I use it , I need to move element on my 2d board game

Hi I would really appreciate if anyone could help me to write a script to move my piece in a game if the player gets no 1 on the dice I know the logic but I am not familiar with c# and unity methods.

Its a simple game where the piece will be in the centre and there will be 4 players the player can roll the dice till it gets no 1 and if he gets no 1 the piece will move opposite side of the player and it will continue among all the players till the piece doesn’t fall out of the board.

I have mapped objects name wave points to navigate through the board I have referred a YouTube video similar to make a board game but its way different and I can’t understand
what does transform .position do so I am not able to implement

private void Move()
{
if (waypointIndex <= waypoints.Length - 1)
{
transform.position = Vector2.MoveTowards(transform.position,
waypoints[waypointIndex].transform.position,
moveSpeed * Time.deltaTime);

if (transform.position == waypoints[waypointIndex].transform.position)
{
waypointIndex += 5;
}
}
}
}

this was from the YouTube video I referred.
Please help me and pls leave down below your discord or any social media handle I can connect to understand.

You need to look into MoveTowards and understand how it works. This will go a long way into getting your code to work as needed. I would start there.

To note, transform.position is the position of the gameobject in the scene. You could easily Google it and get tons of info on it as well. Unity - Scripting API: Transform.position is just a start.

Also, not many (if any) are going to leave their discord or social media. For one, posting it on an open forum like this invites a lot of random people to try to contact us. Then, there is the fact we’re all volunteers and most of us come to the forums to offer help where many can interact and benefit from the help, not just a single person.

1 Like