Hy
Im making a puzzle game where the object need to move in a grid wich i made.
The problem is that I can’t seem to find a tutorial on how to make it so they don’t overlap or are stopped by walls. The colliders don’t work because of the grid based movement.
Their don’t seem to be any tutorials or videos explaining on how to do it.
this is my code so far.
public class move : MonoBehaviour
{
public Rigidbody2D rb;
public bool isMoving = false;
private void Update()
{
if (isMoving)
{
Vector2 movement = new Vector2(Input.GetAxisRaw(“Horizontal”), Input.GetAxisRaw(“Vertical”));
if (movement.x != 0 || movement.y != 0)
{
rb.MovePosition(rb.position+movement);
}
}
}
private void OnMouseDown()
{
isMoving = true;
}
}
any help or ideas?