Hi
I have been making a chees like game in Unity and have gathered some scripts to move a piece. Here is the code below:
It is moving the Selected piece perfectly to the position but I am battling in getting it to Lerp there. I dont know if I am making much sense but it moves directly to the position and I want it to move slowly there.
Any ideas on how to modify the code?
Thanks in Advance ![]()
public void MovePiece(Vector2 _coordToMove)
{
bool validMovementBool = false;
Vector2 _coordPiece = new Vector2(SelectedPiece.transform.position.x, SelectedPiece.transform.position.z);
// Don't move if the user clicked on its own cube or if there is a piece on the cube
if((_coordToMove.x != _coordPiece.x || _coordToMove.y != _coordPiece.y) || _boardPieces[(int)_coordToMove.x,(int)_coordToMove.y] != 0)
{
validMovementBool = TestMovement (SelectedPiece, _coordToMove);
}
if(validMovementBool)
{
_boardPieces[(int)_coordToMove.x, (int)_coordToMove.y] = _boardPieces[(int)_coordPiece.x, (int)_coordPiece.y];
_boardPieces[(int)_coordPiece.x , (int)_coordPiece.y ] = 0;
SelectedPiece.transform.position = new Vector3 (_coordToMove.x, _pieceHeight, _coordToMove.y); // Move the piece
ChangeState (2);
AttackPiece ();
}
}