Swipe on ball to move

I have a 3d model of a ball in front of the camera. Something like this

Is it possible to do a game mechanic where the user swipes his finger and the ball rotates in the direction the finger was swiped, as if the user had kicked the ball? The ball rotates around its own axis and doesn’t move. Even with acceleration, rotating faster or slower depending on how fast the user swipes. How can I go about this? Thanks!

@yaustar is this possible?

Yes it is, it’s gesture recognition that you need to do this

Another developer done something similar here

Thanks @yaustar . How can I apply force to the ball and make it spin based on this force? (the direction and intensity). So not spinning always in the same direction, but the direction of the swipe.

I guess forget about the swipe for a moment. Given a 3d ball, how can I make it spin in with different intensities and directions, based on the force applied to it? I’ll figure it out how to convert a swipe movement to force later.

If it’s a fixed ball which has a rigidbody and is of dynamic type, you would use applyTorque or applyTorqueImpulse

Otherwise, you would have to simulate the ‘spin’ yourself using rotation operations on the entity. For example. For a slow swipe, rotate a small amount per frame. For a fast swipe rotate a large amount.

How much depends on the swipe. The tricky part would to work out the axis of the spin from the swipe. We have a similar example here without the swipe gesture here: Rotating Objects with Mouse | Learn PlayCanvas