Hi to all,
i’ve created a script for rotating an object, but i don’t understand why it dosn’t work…
This is the script:
using UnityEngine;
using System.Collections;
public class RideDampfkarussell : MonoBehaviour {
GameObject teller;
float teller_rot;
void Awake()
{
teller = transform.Find("Corpo").gameObject;
teller_rot = 0.0f;
}
void Start()
{
}
void Update()
{
teller_rot = (teller_rot + Time.deltaTime * 30.0f) % 360.0f;
teller.transform.localEulerAngles = new Vector3(0.0f, teller_rot, 0.0f);
}
}
hope you can help me,
paolo
Hi,
I have begun programming with unity for 3 years, so sorry if I will say, will be wrong.
I think you have too complicated your script. If your rotation is like the earth rotation, you simply write that :
var rotateSpeedX = 1.0f // or what do you want
var rotateSpeedY = 1.0f // or what do you want
var rotateSpeedZ = 1.0f // or what do you want again :)
var rotatedGameObject : GameObject;
function Update () {
rotatedGameObject.transform.Rotate(Vector3(rotateSpeedX,rotateSpeedY,rotateSpeedZ);
}
You can, with this option, use all axis (x,y,z) to rotate your object in all possible rotations.
Good luck for programming.
May the Programmation be with you !
Sorry for my bad english, I’m french.