First of all hello. my ball is constantly bouncing in my project(with physical material).I can do right left back and forth with joystick but the game will be android, I need to throw the ball into the hoop. How can I adjust to throw the ball into the basketball hoop according to the finger drag speed?how can I also ensure that the bouncing ball physical is disabled as soon as my finger touches the screen? I’m waiting yours answer. Thx.
Your browser might or might not have auto translated what i wrote, but i dont speak that language. You also appear to have somehow auto translated code sniplet, because how it looks on the forum, it wouldnt compile.
Touches can be handled similarly to mouse inputs. Just that there can be more than one.
You get a specific “touch” by providing an index to GetTouch:
If there is just one finger, index 0 will provide the corresponding touch.
But there might be 5 or more fingers touching the screen. This is how you differentiate between them.
Touches do have phases. The equivalent to pressing a mouse down would be the touchphase Began, and the equivalent to a mouse up would be the touchphase Ended.
The main thing that’s more complicated here is that there are no “OnTouchDown” events, or things like that. Instead you have to check for touches manually in your Update function. You should find plenty of examples online for how to handle touches. Here are some decent examples to give an overview:
As for how to disable your bounce animation, it depends on how you do it. Effectively you want to detect the situation in which you want to cancel it. For example a finger touching the screen, or letting go of it, to shoot the ball. Then you either disable the animation, or script thats responsible, or you communicate to it, that it should now enter some “shooting mode” or whatever, in which it doesnt animate this bounce.