How to make a Smooth grid based movement with mouse/touch drag
Hi,
I want to make this movement more smoother : GIF link
what i have done so far :
This code is responsible to smoothly move a Cell to its neighbor cell when the player is touching the new cell
void newMove()
{
//Move it
if (Input.GetMouseButton(0))
{
if (selectedCell == null || backupCell == null)
{
return;
}
//got to nextCell
if (underMouseCell != null)
{
if (!underMouseCell.isActive)
{
if (isNeighbor(selectedCell, underMouseCell))
{
iTween.MoveTo(selectedCell.gameObject, underMouseCell.transform.position, 0.5f);
switchCells(selectedCell, underMouseCell);
}
}
}
else if (underMouseCell == null)
{
if (!isTouch)
{
directionalMovement();
}
else
{
touchMovement();
}
}
underMouseCell = getCellFromRay();
}
}
My problem is with moving the selected cell within its own cell i have made many attempts but each has it flows, any help please ?
Thanks
Comment