Ok, so I have this code that I’ve finally kinked all the bugs out of. But after all that the code doesn’t work exactly as intended.
firstly I have 3 “tiles” I want to be able to move by swapping it with an empty transform. But instead of them swapping the “tile” just moves over to the empty transform and the transform doesn’t move to allow for other “tiles” to switch to it.
Here’s the Code:
#pragma strict
var Empty : Transform;
var Tile : GameObject;
function Start(){
Tile.transform.position.y = transform.position.y;
Tile.transform.position.x = transform.position.x;
Empty.transform.position = transform.position;
}
function OnMouseUp(){
if (Vector3.Distance(transform.position,Empty.position)==1){
Tile.transform.position = Empty.transform.position;
Empty.transform.position = Tile.transform.position;
}
}
Any help would be awesome.