在Unity中用Transform控制物体的位置,旋转,缩放
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeTransform : MonoBehaviour {
// 坐标
public float x = 0.0f;
public float y = 0.0f;
public float z = 0.0f;
// 添加一个 Transform 的类
public Transform Mytransform;
void Start () {
// 坐标 旋转 缩放
// eulerAngles 欧拉角
Mytransform.position = new Vector3(0, 0, 0);
Mytransform.eulerAngles = new Vector3(30, 0, 0);
Mytransform.localScale = new Vector3(3, 3, 3);
}
void Update () {
}
}

这篇博客介绍了如何在Unity中通过Transform组件来控制3D物体的位置、旋转和缩放。示例代码展示了如何在Start()函数中设置一个物体的初始位置为(0,0,0),欧拉角为(30,0,0),以及缩放比例为(3,3,3)。这为Unity初学者提供了基础的Transform操作知识。

6482

被折叠的 条评论
为什么被折叠?



