beginner programming woe grids

What I’m currently trying to accomplish is a basic script for movement on a grid.

What I’ve done to begin with: Created a 11 by 11 grid of “Tiles” which are simply GameObject cubes. I have a script to change the color to blue when I mouse over a cube, and to return to it’s original color afterwards attached to each cube(I did so by using a Prefab to make it much more simple). This script works fine, no problems. The problem lies with my next script, meant to create a movement to whichever cube I click on.

using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour {	
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
	void OnMouseUp() {
		iTween.MoveTo(GameObject.FindGameObjectWithTag("Player"), new Vector3(transform.position.x, transform.position.y, transform.position.z), 2f);

This is the current script. It’s basic. I simply want it to move to whichever cube I click on. It works, in that my Player Character(which right now is simply another cube) moves to the cube I click it, it’s just the problem is that it moves downwards into the cube I click on so I end up with only about half a cube sticking up when what I want is entire cube to rest on top of the other cube I’m using for a board.

I half-way resolved the issue by doing the transform.position.y times 1.33, which put the cube on top of the other cube, or at least appearing to be. The problem with that is, if I ever want to raise the up higher than simply that flat terrain, it rests above the terrain(even with gravity enabled…).

The problem APPEARS to be that the cube is moving based on it’s center, which is the very center of the cube and it moves the center of my cube to where I clicked the mouse. How can I fix this?

Sorry if I didn’t explain myself well, I’m rather new to Unity, as you can probably tell.

Yep, as you move with transform, the collision is ignored, or you would have to do it by code.

Now, either

  1. you modify the y value as you did with half of the cube and half of your guy
  2. or use a Character controller which will solve the going down issue
  3. or you place an empty game object at “ground level” on each of the cube and you use this one as target instead of the cube position. Good point about that one, you can create a prefab and whenever you add a cube it has the target attached to it regardless of its height on the world

P.S: Your debug is…unconventional