Hi, How can you create a box whereby you can change xz values of a GameObject in runtime?

Hi, How can you create a box whereby you can change xz values of a GameObject in runtime?

I don’t see any code, so I would imagine you are a beginner. No worries.
You will need to create a simple script, and attach it to the cube. In the inspector you would just modify those value as you wish. The reason why this is in update() is because it is called on every frame.

The position of a game object is accessed through “Transform”.

http://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html
http://docs.unity3d.com/ScriptReference/Transform.html

using UnityEngine;
using System.Collections;

public class Cube : MonoBehaviour {

// Variables
public float positionX;
public float positionY;
public float positionZ;

void Update() {
    gameObject.transform.position(positionX, positionY, positionZ);
}

}

I hope this helps!

Edit 1: Ok what you are looking for then is GUI class. You would probably need a TextArea or a TextField for entering text. And then maybe a button if you want it to only send when you press a button.

http://docs.unity3d.com/ScriptReference/GUI.html

A sample script is below:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float xPositionPlayer;
    public string xPositionString;
    void OnGUI() {
        xPositionString = GUI.TextField(new Rect(10, 10, 200, 20), xPositionString, 25);

    if (GUI.Button(new Rect(10, 10, 50, 30), "New X position"))
        Debug.Log("Send X parameter to the player");
        xPositionPlayer = float.Parse(xPositionString);
    }
}

Note that the TextField is a string, and thus why it needs to be parsed to a float.
Just pass the xPositionPlayer to player, and also you might need to play around with the Rect values.
Also FYI if you really need to get good with GUI stuff there are several tutorials on YT.

Sorry, let me explain it better. I don’t want to modify the xyz values. What I want to do is create a box in the game view whereby the player can enter a value whilst playing and go to that coordinate.