How can i make vertical and horizontal floats not return to 0
Hey, i have a very simple question i think. I have a joystick that gives me 1 to -1 values in horizontal and vertical and when i dont use it it returns to 0. which is to be expected but i need it to remember what it was before letting go.
public void Twist()
{
h1 = joystick.Horizontal;
v1 = joystick.Vertical;
transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Atan2(h1, -v1) * 180 / Mathf.PI);
}
This script rotates my character but when i let go it points in the same direction everytime(Up) And also this only happens when i am in water, so that when im in water it rotates to the way im pointing with my joystick but i can also go on land and i dont want it to remember what values it had for that, but i can figure that out myself since there is a lot of the script you cant see. Any help will be grately apreciated <3
Answer by K00KIE · Apr 23, 2020 at 05:37 PM
Hi bud.
Instead of setting it directly, you should :
Use Rotate() Function
add (+=) Eulers into your rotation.
Your answer
Follow this Question
Related Questions
Transition between two angled planes 1 Answer
Freeze rotation X but rotation Z, how can I do this? 0 Answers
After Rotating a Prefab, Transform.Position of children is inaccurate 1 Answer
2D Sprite issue when rotating towards mouse click location. 2 Answers
He wants to write a script on a page change gait from right to left or vice versa 0 Answers