I have copied my Update of ObjectmovementControl script.Atfirst,when I click and drag my mousepointer,the PuzzlePiece move in the desired way.But if I intentionally try to click on an emptyspace(I put Emptyobject there),the previous update keeps on running…i,e the previous puzzle piece moves on. Please let me know my coding fault.
void Update ()
{
if(mMovestart ) // initially mMovestart= false,so the loop doesnot run when mMovestart=False,it only runs when mMovestart=True
{
_currentObject.position = Vector3.MoveTowards(_currentObject.position,mtargetPos,_movingSpeed*Time.deltaTime);
if(Vector3.Distance(_currentObject.position,mtargetPos)<.1f) // when _currentObject and mTargetPos approaches to zero
{
_currentObject.position = mtargetPos ;
_currentMovingstate = eMovingState.InitialState ;
mMovestart = false ;//in order to keep the condition false .
}
}
}