how to get transform working on null object from imported model?
Hi, I imported an object using Cinema4D. The object is one "empty null" object containing several other empty object that hold regular objects. Now I’m trying to anymate that top most empty object with C# but that just does nothing. I tried:
transform.Rotate (Time.deltaTime * 2, Time.deltaTime * 2, Time.deltaTime * 2);
I also tried other transform methods like
transform.eulerAngles
or
transform.rotation
also
transform.position
none of these work. HOWEVER, when doing this manually: literally clicking the object, then clicking on the "rotation X" value and changing the value manually by tiping in another value, it does work. Why can’t I access it in code?
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move : MonoBehaviour {
// Update is called once per frame
void Update () {
print (transform.rotation);
transform.Rotate (Time.deltaTime * 2, Time.deltaTime * 2, Time.deltaTime * 2);
}
}
do you have any ideas what could be the isse? Thank you.
Ok, so I noticed that it seems to have something to do with the parent object having an Animation Controller attached. If I remove the animation controller, I can change the transformations. Why? How to bypass it and have both woring? Thanks
Answer by chitzui · May 01, 2018 at 07:06 PM
Ok, I got it working. So it was because the animation of the object was using the transform values. So apparently it is not possible to overwrite that in code. So what I did is add another empty element around and animate that one with code instead.
Your answer
![](https://koobas.hobune.stream/wayback/20220612161840im_/https://answers.unity.com/themes/thub/images/avi.jpg)