Skip to content

Instantly share code, notes, and snippets.

@buddypia
Created July 27, 2013 10:16
Show Gist options
  • Save buddypia/6094473 to your computer and use it in GitHub Desktop.
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
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