Hello. I don’t know if the title is clear so I’m uploading an image to make it easy to understand what I’m trying to do I’m making a checkers like game in order to learn with practice.
I have my 2D objects, moving with raycast. Basically teleporting to the point where mouse clicks. Yet I don’t want them to go over each other but I want them to be have to go around.
void posOfClick()
{
Vector3 mousePos = Input.mousePosition;
mousePos.z = 10;
Vector3 screenPos = Camera.main.ScreenToWorldPoint(mousePos);
RaycastHit2D hit = Physics2D.Raycast(screenPos, Vector2.zero);
if (hit)
{
orgPos = (gameObject.transform.position);
tilePos = (hit.transform.position);
transform.Translate(tilePos.x-orgPos.x, tilePos.y-orgPos.y, 0);
}
}
This is how my teleporting system works. Thanks in advance.