C# 如何使用Unity'指定对象的旋转值;s更新功能
我想指定统一的对象旋转值 我不想旋转对象 我编写了以下代码C# 如何使用Unity'指定对象的旋转值;s更新功能,c#,unity3d,C#,Unity3d,我想指定统一的对象旋转值 我不想旋转对象 我编写了以下代码 using System.Collections; using System.Collections.Generic; using UnityEngine; public class test_rotate : MonoBehaviour { int test_x = 10; // Use this for initialization void Start () {
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test_rotate : MonoBehaviour {
int test_x = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
this.transform.Rotate(test_x, 0, 0);
}
}
然后对象开始旋转
这不是我想要的
我只想将对象的旋转值设置为(10,0,0)
我还尝试了以下代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test_rotate : MonoBehaviour {
int test_x = 10;
// Use this for initialization
void Start () {
this.transform.Rotate(test_x, 0, 0);
}
// Update is called once per frame
void Update () {
}
}
然后它按预期工作,但是我想用Update函数而不是Start函数来完成这项工作
我该怎么办?transform.Rotate()
每次调用对象时都会旋转它
您要做的是设置变换的旋转:
transform.rotation=Quaternion.Euler(test_x,0,0)代码>如果只想设置一次,为什么要在更新(每帧运行)中执行此操作?