Moving a Object to center of a member of a list .
Hey guys. I am making a color game that I wanna player can drag and drop current color to a piece .for this I used this code .
foreach (var piece in Piece)
{
if (Vector2.Distance(CurrentColor.transform.position, piece.transform.position) < 1f &&
!CurrentColor.GetComponent<DragDrop>().dragging)
{
piece.layer = CurrentColor.layer;
CurrentColor.transform.position = Vector2.Lerp(CurrentColor.transform.position, piece.transform.position,
1f * Time.deltaTime);
}
}
my problem is when I ending drag if piece row is between 2 and 6, it moves to avg position of the two-piece. I attached an Image from my problem. what is wrong here? sry for my bad english.
[1]: /storage/temp/153918-new-text-document.png
new-text-document.png
(7.1 kB)
Comment
Your answer
Follow this Question
Related Questions
C# How can create a list of floats from different types of structs? 0 Answers
How to create a Knockback vector2 directions script (c#) 1 Answer
What are the parameters passed in vector2? 0 Answers
Lerp a vector2?,Lerp a Vector2? 0 Answers
Rotate a Vector2 around the Z axis on a mathematical level 1 Answer