So I want to rotate this cube...
in a game I want to rotate a cube. I wrote a script to rotate it but when it rotates the cube scales weirdly but still rotates. Here's my code, but whenever I rotate anything in the scene it also scales the same way.
using UnityEngine; using System.Collections;
public class Rotate : MonoBehaviour {
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (45, 10, -100) * Time.deltaTime);
}
}
Is your parent scaled? If so, try setting your parents scale to 1, 1, 1.
Answer by jonofarc · Nov 10, 2015 at 08:59 PM
This happens because the father object of your cube has a transform scale different from 1,1,1 (2,2,2 3,3,3 .... n,n,n) if you want to prevent this you can just either:
-remove the cube from the father object
-create and empty gameObject that has a 1,1,1 world scale (I mean that when he has no parent the scale would be 1,1,1) then make it a child of "point/score" and then make the cube the child of the empty GameObject
-make sure the father object of the cube has a scale like 1,1,1 ... n,n,n
Weird, I only thought it was the case when it was non-uniformly scaled, like (3, 0.5, 0.7). You learn something new every day.
Edit: Ah, thought you meant it happens when it is uniformly scaled. I understand you now.
Your answer
Follow this Question
Related Questions
How to rotate wheel colliders on the Y axis since they can't be rotated in the editor? 0 Answers
Roll/rotate a cuboid at its edge 2 Answers
Roll cuboid does not work properly 1 Answer
Move sphere around a cube using conventional physics 1 Answer
Rotating & fixing the position of an object to one spot 1 Answer