- Home /
Rotate object of certain degree on button press
Hello! Than’s you in advance for any help!
I have to rotate of 90 degree my object when a button is pressed, right now i’m able to do it, but is going back to 0 when a button is up...
Any help?
$$anonymous$$aybe give us your code? You said you can do this, but it goes back so there is something else that is rotating your object, t oindentify this we need to see the code
Yes, you’re right i’m sorry..
I have it on my computer but is same as this.
The input value is a mouse input on range 0,1
Quaternion currentRotation;
Float angle = 90f;
Private void SetRotation ()
{
Float newAngle = $$anonymous$$athf.Lerp(currentRotation.y,angle,mouseInput);
currentRotation = Quaternion.Euler(0.0f,newAngle,0.0f);
Transform.rotation = Quaternion Slerp(transorm.rotation,currentRotation,.5f);
currentRotation = transform.rotation;
}
It’s same as this..
Answer by tormentoarmagedoom · Oct 10, 2018 at 12:26 PM
Good day.
In your code, you use mouseinput to set the rotation....
Mouseinput is a variable that become 1 while the mouse is pressed . And 0 while is not pressed..
You need to make a method to activate only once when detect with Input.Getkeydown.
Bye.
Actually i need to use it with the mouse range from 0 to 1
Your answer
Follow this Question
Related Questions
Build rotation tool for level editor 0 Answers
How to find or compute or look for overall/max RPM by simply checking for rotation? 1 Answer
Quaternion LookRotation issue 0 Answers
How to "clamp" a y rotation in unity? 0 Answers
How to Rotate Plane of Cube Around its Center? (Rotate Vectors Around Point/Axis/Direction) 1 Answer