How i can make continuous rotation of an object from the x to the z axis ? can someone help me? ?
1 Answer
1You can manually set a Vector3’s xyz values so you can just increment one value in the Update function and set the target objects rotation to it.
private Vector3 new_rot = Vector3.zero;
private float speed = 2.0f;
void Update(){
new_rot.x += speed;
transform.eulerAngles = new_rot;
}
Not sure what you mean by from the X to Z axis…
No, it will. I even tested it just now, it will increment new_rot's x axis by speed every frame, it's not interpolating or anything.
– Josh707I said it won't work right, not that it won't work at all. You absolutely need to use Time.deltaTime or your movement will be framerate-dependent, which is unacceptable.
– Eric5h5Ah, okay, I knew it would add every frame but didn't catch on to what you meant by working right
– Josh707It's not just the deltaTime that's missing - by initiating new_rot as Vector3.zero, you're also cancelling out any existing rotation of the model in the x and z axes. Rather than setting eulerAngles directly, use the built in Rotate() function (that's what it's for!). See my answer in: http://answers.unity3d.com/questions/571797/continuous-rotation-of-an-object-script-1.html
– tanoshimi
This is the third time you've asked the exact same question in the last 24 hours. People have answered you each time and you never responded to them. This borders on abuse of the site. It's also rude to the people who spent the time trying to help you. Use the site properly and respectfully or don't use it at all.
– HuacanachaSee my previous answer to your question in http://answers.unity3d.com/questions/571797/continuous-rotation-of-an-object-script-1.html Which is the same as @RobertBu's answer in http://answers.unity3d.com/questions/571888/continuous-rotation-of-an-object-script-2.html
– tanoshimi