How to develop a scrollview with inertia in Unity?

浪子不回头ぞ 提交于 2019-12-13 04:23:31

问题


I want to develop a "scrollview" in Unity.

Basically I have a Parent Game Object on the screen with many items inside it. The Parent Game Object is big enough so it goes outside the screen.

I developed a scrolling script so when the user drags the parent object, I move it and it looks like scrolling.

I did this by implementing the OnMouseDrag event.

How can I calculate the inertia and apply it so when the user drags it fast, it continues to move?


回答1:


What you want, the effect that you want, is called kinetic scroll/scrolling/panning .

Here is an answer with a generic algorithm in it, I'm sure that with this keyword in mind you will probably find a ton more of examples.

Next time watch out for the tags, your first set of tags was incorrect, other frameworks have the same unity name .



来源:https://stackoverflow.com/questions/23637598/how-to-develop-a-scrollview-with-inertia-in-unity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!