- Home /
Trying to draw a tongue on screen using touch.
I am making a game where the main character uses his tongue to gather things. So I need to figure out how to let the user click on the screen with their finger and have a tongue appears from the middle of the screen to the place the player touched. Does anyone have any ideas?
The key word here is that you said "I need to figure out how to..." and yes. yes you do.
Answer by Thom Denick · Jul 24, 2012 at 07:37 PM
This is not a particularly difficult task, but you need to understand the basics of Unity, and in particular object movement and raycasts.
If you don't understand what i'm talking about below, get started by walking through the Unity tutorials on the Unity site.
Create a vertically scalable tongue object. There are a number of different ways you can do this. Either by stacking several game objects on top of each other or have a gameobject that looks ok when stretched massively vertically.
Listen for mouse clicks in an Update. When a mouse is clicked move the end of your stretchable game object to the mouse x,y point. Fancy it up with animation.
Put some kind of collider on the end of the tongue, if this collider hits an edible object, handle it how you want in your game.
This is not an easy gameplay mechanic to implement for someone brand new to Unity. You need to know a lot about Unity. I recommend starting here: http://unity3d.com/support/resources/tutorials/
will this work for a touch screen game too or just mouse?
For Touch Input, you'll want to use Raycasts from touches. You can find out more about how to do that here: http://answers.unity3d.com/questions/222121/raycast-from-player-to-touch-point.html?sort=oldest
how do you move the end of your stretchable game object to the x y mouse position?