Trying to implement EasyTouch gestures into 2D game

Hi,

I am trying to implement EasyTouch touch screen gestures and “Camera Transitions” into our 2D game. This is actually a re-release of an older game, and while the game is 2D, it has 3D graphics, and has no player character (played as first person perspective). Point and click adventure, basically, but we would like to add gestures for mobile devices. So what I would like to happen is that when someone swipes the screen, it will change to another camera. I don’t see a way for that to happen so far. Here is the script I am trying to use:

    public Camera camorig;
    public Camera camleft;
    public Camera camright;

    // Use this for initialization
    void Start () {
       
    }
   
    // Update is called once per frame
    void Update () {
       
    }

    void On_Swipe (Gesture gesture) {

        CameraTransition cameraTransition = GameObject.FindObjectOfType<CameraTransition>();
        if (cameraTransition == null) {
            Debug.LogWarning (@"CameraTransition not found.");

        }

        else {
            if (gesture.swipe == EasyTouch.SwipeDirection.Left) {

                cameraTransition.DoTransition (CameraTransitionEffects.Fold, camorig, camleft, 1.0f);

            } else if (gesture.swipe == EasyTouch.SwipeDirection.Right) {

                cameraTransition.DoTransition (CameraTransitionEffects.Fold, camorig, camright, 1.0f);

            } else {
                Debug.LogWarning (@"Swipe not completed.");
            }
               
        }       
    }

So I don’t know if I am going about this the correct way or not. I have tried attaching the script to the camera, and to the hotspot, to no avail. I have also tried attaching script to “Quick Swipe” component, to both camera and hotspot, but that doesn’t allow me to define the camera variable in my script. I know most people attach the component and/or script to a game object, but this game is quite different, and we aren’t using game objects at all. I’m not sure how I would attach a game object to a camera so that it would know which camera I am on, so it would know to which camera to transition. I am very new to C#, so anything that you think is helpful would be much appreciated.

First, please use code tags when doing scripts Using code tags properly - Unity Engine - Unity Discussions

Second, you are using gameobjects, otherwise what do you have in your scene? Even your camera is a gameobject. And if nothing else, you can also add empty gameobjects.

So, I’m not familiar with EasyTouch. The question is, the script you posted is your own script? How is On_Swipe being called? Are you sure this isn’t suppose to be in Update?

Sorry about that. Code tags added. I am new to Unity too, so I didn’t understand the scope of game objects. In our game, we have static images that each have an individual camera above them on a 2D plane.

I have uploaded the pdf of the documentation for EasyTouch. I made the script myself, but EasyTouch has a number of events you can call, one of which is On_Swipe(). I assume if I am wanting to implement a swipe that I would use the On_Swipe event, if that is the right terminology.

3202895–244893–EasyTouch.pdf (791 KB)

Did you add the EasyTouch to your scene based on their Quick start guide?
Or did you setup an EasyTouchTrigger if you’re using that instead?

Well, I had done neither before this thread. I had just looked over the documentation to see what I would need to write my script. I don’t think I can use the trigger because I need to pass more parameters than it allows.

I did a ton of testing this afternoon, and I realized that I needed to add some things in the documentation. Kept thinking I was getting close, but nothing. Finally, just to see if it was even working at all, I created a completely fresh project, and followed the quick start guide TO THE T. I can’t get it to work. I am wondering whether there is a basic conflict one of my other add-ons: Adventure Creator and Camera Transitions. Also, this is all in 2D, and idk if that is an issue either.

I’m turning green!

But really, thank you for your help!

I started a new project without any of the other add-ons. still not working. Either their documentation is missing something, or there is a conflict with unity. I may just have to go with another addon.

Maybe look at lean touch Unity Asset Store - The Best Assets for Game Making

It’s free and has great ratings. Haven’t looked at it myself though.

Thank you for that recommendation. Lean touch is something that I think will work much better for our purposes.