- Home /
Joystick Zone + Screen-swipe touch input clash. Solution???
Hello.
I'm making a 3d third person game for android/iOS. It has a main character in the middle of the screen that is controlled by a virtual touch joystick, and the screen can be touch-swiped across the screen to make the camera orbit around the character.
This is part of my script to rotate camera by screen swipe:
void Update()
{
if (target && Input.touchCount == 1 && Input.GetTouch(0).position.x > Screen.width && Input.GetTouch(0).phase == TouchPhase.Moved) //Just orbit touch without movement
{
Debug.Log("Orbiting! 1 touch");
Orbit(Input.GetTouch(0));
meaning if I touch anywhere on the screen and drag it, it will direct to a void that would rotate camera. However, my problem is I also have a joystick at the bottom left corner of my screen, so if I touch and drag the joystick to move, it will also rotate the camera which is not what I want.
When I touch the joystick region, I do not want the screen-swipe to interfere.
Are there any ideas as to how I can tackle this problem? I'm new to scripting C# so it would be much appreciated if answers are explaining for newbs.
Thank you.
Answer by Graham-Dunnett · Jun 27, 2014 at 12:03 PM
Write code that works out where on the screen the Touch has started, and enable or disable your movement and orbit code accordingly.