Hello everyone!
I have been working on first person controls for my game for mobile devices. What I wanted to do is that if the player touches the screen and swipes around he can move the camera, just like in any other mobile FPS game. Here is what I tried:
foreach (Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
}
else if (touch.phase == TouchPhase.Moved)
{
obenuntenRot -= Input.GetTouch(0).deltaPosition.y * rotateSpeed * Time.smoothDeltaTime;
linksrechtsRot += Input.GetTouch(0).deltaPosition.x * rotateSpeed * Time.smoothDeltaTime;
this.transform.localEulerAngles = new Vector3(obenuntenRot, linksrechtsRot, 0.0f);
It works fine, but the problem is that it feels really clunky and not as smooth as I am used to. Are there any other ways which can make this really smooth?
I suggest that you make a “virtual point” that you manipulate, that virtual point represents the orientation that you want to look at , then at every frame you lerp your camera orientation towards that point with a certain speed and easing algorithm that feels right - that way you can control how smooth or sluggish the head of the follows your fingers.
That approach can be tweaked also so that it follos your fingers more closely when shooting and diffirennt when running to create an optimized experience.
You can just create another Transform/GO that you manipuate intstead of the camera and just Lerp the Orientation and snap the position of the camera to it every frame, that should be a pretty straight forward way of doing it.