Physics with gestures

Wondering if someone could help me on this one. So for this simple test I need a rectangle to rotate on a specified axis from the users swipes input. Should support multiple axis rotation. Also need a way to instantly stop the rotation with user input , all this done with physics

velocity = speed/time

Depending on your swipe input, if you can’t get the velocity but can get the distance moved upon release, you can get the velocity by simply dividing the value by Time.deltaTime. If your object has a dynamic Rigidbody you can use this swipe velocity maybe with a multiplier and AddTorque. Adjust the rotation slowdown with the AngularDrag property of the RigidBody.

As for stopping, I think you are looking at 2 ways to rotate your object, one when the user has their finger down on the screen, and one when the user has swiped. Swipe should use what i just mentioned above. finger down would affect the object rotation directly rather than adding torque. The rotation applied while the user has their finger down could use the distance moved by the user’s finger directly, or the calculated velocity as per the above method.

Hope it gives you some ideas.

Thanks for the reply it was helpful. Made we wonder if it possible to parent multiple dyn rigid bodies and constrain them to only one axis, a sort of rotation order.

You really should read up on the API to explore your options with Rigidbodies. With regards to contraints, have you seen the rigidbody constraints?

I don’t understand what you meant by parenting “multiple dynamic rigidbodies”. What are you trying to make?

The idea is to solve rigidbodies in a constrained axis then patent it local rotation to a parent rigidbody. It spinning a wheel within a wheel on different axis

Are you trying to mimic a gyroscope toy? In any case, you should check out the several different physics joints and the wheel collider. They should contain the solution to what you just described.

Cool thanks Laperen