Question by
Alex656 · May 14, 2020 at 11:16 PM ·
c#quaternionsmooth
Can't make smooth rotation using joystick
I tried to do smooth rotation using joystick this code works almost like I want, but when i take my hand from joystick,character always turns in one direction
I use free joystick pack asset
here is my code:
public void FixedUpdate()
{
Vector3 direction = Vector3.forward * joystick.Vertical + Vector3.right * joystick.Horizontal;
rb.AddForce(direction * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
transform.Translate(Vector3.forward * forwardspeed);
Quaternion LookRotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Lerp(transform.rotation, LookRotation, Time.deltaTime * (degreesPerSecond / 360f));
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612234316im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Clamping camera rotation 1 Answer
Grappling hook physics script error 0 Answers
Smoth LookAt Unity c# 0 Answers
Swapping Right handed Quaternions to left handed from streaming data. 1 Answer