I’m directly getting input from my Horizontal axis and assigning it to quaternion.x which is then set as the rotation to my object.
but even the slightest change in the quaternion (less than 0.00001) snaps the rotation to 180 degrees on any axis.
Here’s my code:
Im trying to get the axis to directly controll the degrees of rotation on x axis.
I have two solutions in mind. I will do the extra work for you, just let me know one thing: Do you want this to rotate for as long as you hold the button down, or do you want this to have a max angle of rotation?
With maximum angles. I tried that with Mathf.clamp, but it changed nothing. im trying to copy a mobile device tilt axis to the angle of the game object with limits. THe tilt axis stuff is all worked out, its just the rotation itself that doesnt behave as expected.
First, is the one you asked for, using a maximum angle for your object. The drawback with using this one, is that you will not have control over how quickly your Input.GetAxis accellerates to 1 or -1.
This second method simply rotates in the direction you are holding down, based on a fixed speed. Now, you can obviously alter this to your liking with an if statement to measure against the current rotation, so it has the potential to be a better solution if you need that rotation speed.
then i think the problem is that you are having problem loading material from resources ... i would advice you to make a public variable for material and drag drop your material from inspector ... if you still want to use your original approach then please make sure that your material is in Resources folder (or Resource folder, just a bit confused ^^)
I have two solutions in mind. I will do the extra work for you, just let me know one thing: Do you want this to rotate for as long as you hold the button down, or do you want this to have a max angle of rotation?
– JadeTheFlameWith maximum angles. I tried that with Mathf.clamp, but it changed nothing. im trying to copy a mobile device tilt axis to the angle of the game object with limits. THe tilt axis stuff is all worked out, its just the rotation itself that doesnt behave as expected.
– J-Fthen please show us Renderer of m_world ... update the above picture
– aditya