Hi All,
I’m working on a 2D tile based game. I am able to move the tiles/chips around as normal, but now feel that having the world ‘appear’ 3D would look better.
What would be the best approach to make the world appear 3D while still constraining the movement to the current 2D plane?
if (Input.GetMouseButtonDown(0)) {
Vector2 point = controlCamera.ScreenPointToRay(Input.mousePosition).origin;
hit = Physics2D.Raycast(point, Vector2.zero);
if (!hit.transform) return;
pressedChip = hit.transform.GetComponent<Chip>();
pressPoint = Input.mousePosition;
}
if (Input.GetMouseButton(0) && pressedChip != null) {
Vector2 move = Input.mousePosition;
move -= pressPoint;
if (move.magnitude > Screen.height * 0.05f) {
foreach (Side side in Utils.straightSides)
if (Vector2.Angle(move, Utils.SideOffsetX(side) * Vector2.right + Utils.SideOffsetY(side) * Vector2.up) <= 45)
pressedChip.Swap(side);
pressedChip = null;
}
}
public Chip GetChipFromTouch() {
Vector2 point;
if (isMobilePlatform) {
if (Input.touchCount == 0) return null;
point = controlCamera.ScreenPointToRay(Input.GetTouch(0).position).origin;
} else
point = controlCamera.ScreenPointToRay(Input.mousePosition).origin;
hit = Physics2D.Raycast(point, Vector2.zero);
if (!hit.transform) return null;
return hit.transform.GetComponent<Chip>();
}