- Home /
transform.rotation only y axis?
Hy, i want to rotate in javascript a planet. In this time the Earth is this planet, and it has a constans 23.5 degree X axis rotation, and must 0 degree z axis. My problem:
simple transform.rotation not working correctly Vector3.left working, but all three axis are rotating (but why if i defined the x,z axis to zero?...)
Any help? Thanks a lot.
The Earth is a rigid body? You can freeze the rotation in the wrong directions.
It's a unity sphere with an image only, and added rigidbody but the rotation freeze not worked.
Answer by zharik86 · Jun 25, 2014 at 08:36 PM
If you want rotate object with only one itself axes, for example y, then using function Rotate:
private var speed:float = 5.0;
function Update() {
transform.Rotate(Vector3.up, speed * Time.deltaTime, Space.Self);
}
Thanks i try this code, but i used something similar. Why the var is private?
@stormrider1991 Private the variable doesn't play an essential role. Simply I made it as private. You can make it as public. Simply delete the word "private" in my code and it will be "public". The code is checked by me long ago. Rotation of a planet will happen on its axis (if certainly vertical is a y axis). If you use something similar, you shan't have problems.
Your answer
Follow this Question
Related Questions
How to randomise object facing upon button down (using raycast to detect cursor over object) 1 Answer
Need to change direction of transform? 2 Answers
Playing sprint animation with vertical axis? 0 Answers
Wrong if command 3 Answers
LookAt Problem 1 Answer