- Home /
Question by
Pepa01 · Mar 28, 2015 at 04:50 PM ·
2d gamemobiletouch2d controller
simple 2D controller for touch screens (arrows left/right/up/down)
Hi,
I´m a newbie in unity. I want in my game (for mobile phones) use simple 2D controller for my gameObject. I don´t want nothing complicated only at the bottom left corner of the screen add left, right, up, down arrows. That´s it.
When user click on it, the character should move to the right direction.
In my project I have for now this:
if (Input.GetKey(KeyCode.RightArrow))
dir = Vector2.right;
else if (Input.GetKey(KeyCode.DownArrow))
dir = -Vector2.up; // '-up' means 'down'
else if (Input.GetKey(KeyCode.LeftArrow))
dir = -Vector2.right; // '-right' means 'left'
else if (Input.GetKey(KeyCode.UpArrow))
dir = Vector2.up;
I tried to google some tutorial or hint but I didn´t find anything useful. I don´t need complicated joystick with different directions.
Comment
Answer by Graham-Dunnett · Mar 28, 2015 at 04:51 PM
Try reading the docs:
What exactly do you mean? I don´t want use some touches on the whole screen area. Can you write more info about it? What I should use for it? Or add link to some specific article.