Unity translate rotate an imported object

时间:2017-06-15 09:37:25

标签: c# unity3d

i can't translate.rotate (0,5,5) in unity on an imported model

what should i do to make it rotate i can't find a good source.

my code is here: i put script under gear or main camera but it doesn't rotate i also selected model name on script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {
    public GameObject gear;
    // Use this for initialization


    // Update is called once per frame
    void Update () {
        gear.transform.Rotate (100, 10, 10);
    }
}

enter image description here

1 个答案:

答案 0 :(得分:2)

According to your image, you don't do it corretly. Follow these steps :

  1. Drag the Gear model from the Assets and drop it into your scene
  2. Select the Gear GameObject in your scene
  3. Drag the NewBehaviourScript from your Assets and drop it to the inspector of the Gear Gameobject
  4. Drag the Gear Gameobject in your scene to the public field gear of the NewBehaviourScript attached to the gear gameobject

If you feel the 4th step is useless change the script as follow :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

    // Update is called once per frame
    void Update () {
        transform.Rotate (100, 10, 10);
    }
}