[ad_1]
I discovered an answer utilizing Quaternion.LookRotation()
–
I used it to translate the swipe gesture to a Vector3 that’s representing the course.
I used this code contained in the Update()
methodology to retrieve the person’s enter:
if (Input.touchCount > 0)
{
currDirectionX = Input.touches[0].deltaPosition.x;
currDirectionZ = Input.touches[0].deltaPosition.y;
}
transferDirection = new Vector3(currDirectionX, 0f, currDirectionZ).normalized;
and this code contained in the MountedUpdate()
methodology to rotate in the direction of the specified rotation, whereas continuously transferring ahead in native area:
Quaternion targetRot = Quaternion.LookRotation(transferDirection);
this.remodel.rotation = Quaternion.RotateTowards(this.remodel.rotation, targetRot, 8f);
rb.AddForce((pace * remodel.ahead) - rb.velocity, ForceMode.VelocityChange);
[ad_2]