How to make a ball swipeable?

hey together,

first ive to tell you that im new to unity and coding games.
ive many experience with cinema 4d and so, the interface of unity was clear :slight_smile: but on the other hand i only have some experience with javascript for simple html pages. not much!

for the first time, i want to make a little minigolf game, where you can swipe against the ball and goes in the direction. but i havent any clou how to start… ive made a ball, a minigolf course and some tiny little features (blocs you have to avoid)

so which code should i place on which element, that it works?

thank you!

It sounds like you are trying to create a mobile(touch) game.

I don’t think anyone is going to give you the code/scripting you’re looking for, but who knows.

At a high level without code and regardless if you are using the mouse or touch to perform the “swipe”…

You will need a script that is aware of the ball and the input from the user.
You will need to capture the starting position(first touch/click) and the ending position(removing finger/button no longer held), that will give you some force if you will. The time between the beginning of the touch/click and the release will help determine the magnitude, the direction should also be evident from the touch/click beginning and ending locations.

That is my two cents and should at least, even if i’m wrong get your brain working.

As Landern suggested, however in combination with mobile touch - use raycasting?

you were right, it is for a mobile game!
and its about that i needed something to start with not that im lazy to do it on my own! i will try that raycast script help and thanks to you both.

There’s a package called “FingerGestures” which is useful for this type of thing; it recognizes various types of swipe/tap/drag and gives you the relevant information about them.