How come an object doesn't rotate when the Transform -> Rotation value gets changed?
So this is when I manually changed the rotation value(y) in the inspector tab.
This works fine as expected.
Now, this is after I played the game and input the key(left arrow).
As you can see, the Rotation value has been changed, yet the object remains still.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Body_Rotation : MonoBehaviour
{
[Header("Property")]
private Transform myTransform = null;
public float DegreesPerFrame = 0.06f;
// Start is called before the first frame update
void Start() => myTransform = GetComponent<Transform>();
// Update is called once per frame
void FixedUpdate()
{
Vector3 dAngle = new Vector3(0f, DegreesPerFrame, 0f);
if (Input.GetKey(KeyCode.RightArrow))
{
myTransform.Rotate(dAngle);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
myTransform.Rotate(-1.0f * dAngle);
}
}
}
This is the code I wrote.
And the unity version is 2018.4.21f1.
Answer by Bunny83 · Apr 27, 2020 at 03:28 PM
You have your "static" checkbox checked. As you can even see at the mesh filter your mesh actually isn't rendered at all since it got batched into one big static mesh. Never ever tick that static checkbox for any object that isn't static. As soon as you have any dynamic aspect on that object (movement, rotation, material change, ...) it must not been marked as static.
Your answer
![](https://koobas.hobune.stream/wayback/20220612232601im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make the rotation of a child object of object A match the rotation of object B ? 0 Answers
i'm using a code to make my cube walk with character controller but when i play the cube spins. 0 Answers
Unity 2D lookat and shoot issues 0 Answers
GameObject not looking at me.. 1 Answer
how do I rotate an object without affecting later rotation? 0 Answers