- Home /
touch input speed to camera rotate speed. scaling function needed
I have a camera attached to the head of my player and i use touch inputs to control where the player looks. The problem is that i want to scale the movement of the players look depending on the speed of the swipe. for example a slow swipe should move the players head slowly and give more precision on where to look and a fast swipe should move the players look direction quickly so they can react to the world quickly.
The current solution i have is to look for a threshold value on the input and scale this vlaue but i would prefer a method that does not work on a threshold value. but works on some kind of scaling function but i cannot find an answer that reacts correctly, ether te function is too quick or too slow. what is a common solution to this problem?
My current solution
void OnDragging(DragInfo dragInfo)
{
if(dragInfo.delta.magnitude * Time.deltaTime < 1.1f )
{
dragDelta = (dragInfo.delta / 4.0f); //Vector2.Lerp(dragDelta, dragInfo.delta / 4.0f, Time.deltaTime * 100f);
}
else
{
dragDelta = dragInfo.delta;
}
}
Your answer
Follow this Question
Related Questions
Unity input to rotate camera 0 Answers
help with my orbit camera script 0 Answers
Help with rotating Camera around Pivotpoint(from A to B) 1 Answer
Touch mouseorbit 5 Answers
Transform.position of child object not working as intended. 1 Answer