- Home /
How do I drag a 3D object as if it were in a slingshot (touch-based)?
I would like to design a slingshot that is similar to the following demonstration: http://www.youtube.com/watch?v=TNCkxEqwEK0
However, there are a few major differences:
This would be on a touch-enabled device on iOS or Android.
Dragging down would actually bring the object closer to you.
Creating a dead-zone above the object to prevent you from dragging up.
I am a beginner and am first trying to figure out how to drag the object so that the following behaviors occur:
Drag left/right - The object moves to the left/right.
Drag down/up - The object moves closer towards/farther away from you.
Can someone show me a quick example of how I would implement something like this?
Answer by pako · Dec 29, 2012 at 11:18 AM
I can't provide you with a quick example but I'll try to point you in the right direction.
There are 3 main elements to what you want to do:
The touch screen interface
The rendering of the sling shot (GUI)
The physics logic
Especially since you are a beginner, I would advise that you check out the asset store for available solutions.
My personal favorites are Virtual Controls Suite (VCS) for touch screen, and NGUI for GUI.
For the physics logic: Unity Physics engine would do most of the work as long as you attach a Rigidbody component to the sphere game object, or whatever other object you want to shoot with your sling shot.
EDIT: If you want the sling shot to move on the z-axis then it would need to be created in a 3d modelling package (e.g. Blender).
Your answer
![](https://koobas.hobune.stream/wayback/20220613090054im_/https://answers.unity.com/themes/thub/images/avi.jpg)