Created
September 6, 2016 20:23
-
-
Save sabotai/edfc381bcccbf67de3f9ca65c2b7d9a1 to your computer and use it in GitHub Desktop.
gd205 week 2 homework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Move : MonoBehaviour { | |
public int playerX, playerZ; | |
public GameObject textObject; | |
// Use this for initialization | |
void Start () { | |
//playerX = 5; | |
//playerZ = 10000; | |
//Debug.Log (transform.position); | |
transform.position = new Vector3(playerX,0,playerZ); | |
textObject.GetComponent<TextMesh> ().text = "test"; | |
} | |
// Update is called once per frame | |
void Update () { | |
playerZ = (int)transform.position.z; | |
playerX = (int)transform.position.x; | |
if (Input.GetKeyDown (KeyCode.UpArrow)) { | |
transform.position += new Vector3(0,0,1); | |
} | |
textObject.GetComponent<TextMesh> ().text = "Position: (" + | |
transform.position.x + ", " + | |
playerZ + ")"; | |
if (playerX == 0 && playerZ == 2) {//player is at the bad position | |
Debug.Log("reset the player's position"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment