0
\$\begingroup\$

Im building a tower defense game on unity and would like to allow the player to pan the camera on a large map. I am using touchscript to handle the touches.

I made a testing project with the following hierarchy
Main Camera
Panning object
Sprite

I am using the pan gesture to move the panning object which then sets the main camera's position to negative of the panning object's corrds.

So far, the things that should work worked properly. There is however the issue that the sprite object is higher up the layer and thus take priority. This means that if the viewport is filled with the sprite object, you are no longer able to pan as you cant touch the panning object behind the sprite object.

So the question is,
1. How does touchscript handle layering?
2. How can one achieve a passthrough effect where the sprite would handle tap gestures and the panning object handles pan gestures?
3. Can anyone suggest a better touch system for what im trying to do other than touchscript?

Thanks

\$\endgroup\$
1
\$\begingroup\$

By using raycast, you can accept touch gesture per layer (see unity Raycast documentation). I think it's better to put panning object and your sprite on different layer. Then you may check for raycast colliding with your panning object and sprite.

I think it's better to use different touch gesture, like tap for interacting with sprite and sliding fingers across screen to trigger pan (by checking touch.phase)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.