- Home /
Rotation Script Changes the Object Axis Inclination Too
Hi Everyone,
I have a rotation script for the rotation of a planet (The Earth) but the planet has a 23,67 inclination degrees on its own axis (on the Y rotation vector of the Sphere Object), and the rotation script works fine at any speed until i give the planet object its proper inclination degrees, then , when i change the speed of the rotation, the sphere wont mantain its correct axis and change its inclination, this is the script:
var rotationSpeed: float = 15;
function Update() {
// planet to spin on it's own axis
transform.Rotate(transform.up * rotationSpeed * Time.deltaTime, Space.World);
}
Thanks to any Help :)!
You have used Space.World in the rotation so that transform.up now means world space up ie the Y axis
Hi, thanks for the fast answer!, but when i put "Space.Self" ins$$anonymous$$d, it gets crazy and rotates everywhere....
...Interesting, when i use transform.right ins$$anonymous$$d of transform.up in the script, the object rotates well on its own center at any speed, dont know why....
Answer by Edyvargas · Sep 02, 2014 at 04:33 AM
SOLVED!, in the first code i changed transform.up for Vector3.up, and its working great now, thanks and hope this helps to anybody with a similar issue, the working code its this:
var rotationSpeed: float = 15;
function Update() {
transform.Rotate(Vector3.up rotationSpeed Time.deltaTime, Space.World);
}
Answer by Edyvargas · Sep 02, 2014 at 02:58 AM
I found that using the RotateBehaviour.cs script from the Standard Assets, the sphere object rotates fine on its own pivot center even after of being tilted some degrees, but i need to use it in the javascript code, any idea? thank you:
using UnityEngine;
using System.Collections;
//Decompile by Si Borokokok
public class RotateBehaviour : MonoBehaviour
{
public Vector3 RotationAmount;
private void Update()
{
transform.Rotate((Vector3) (RotationAmount * Time.deltaTime));
}
}