Created
July 27, 2013 10:16
-
-
Save buddypia/6094473 to your computer and use it in GitHub Desktop.
【Unity】【NGUI】NGUIにVirtual Joystick(NGUI用)を追加してみた ref: http://qiita.com/shori0917/items/0b3237eb13889d3ea053
This file contains 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
UIJoystick joystick; | |
void Start() { | |
this.joystick = GameObject.FindGameObjectWithTag("Joystick").GetComponent<UIJoystick>(); | |
} | |
void Update() { | |
if (this.joystick.position.y > 0) | |
{ | |
transform.position += new Vector3(0, _speed * Time.deltaTime, 0); | |
} | |
else if (this.joystick.position.y < 0) | |
{ | |
transform.position -= new Vector3(0, _speed * Time.deltaTime, 0); | |
} | |
if (this.joystick.position.x > 0) | |
{ | |
transform.position += new Vector3(_speed * Time.deltaTime, 0, 0); | |
} | |
else if (this.joystick.position.x < 0) | |
{ | |
transform.position -= new Vector3(_speed * Time.deltaTime, 0, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment