[Unity游戏开发]常用类之Transform类

Transform组件作用: 
 1. 负责游戏对象的变换(位置,旋转和缩放) 

 2. 维持父子关系

Transform组件主要是有Position,Rotation和Scale对应着位置,旋转和缩放。

常用属性

属性说明
position世界坐标系中transform的位置
localPosition相对于父物体的位置
eulerAngles欧拉角,旋转的角度
rotation世界坐标系中变换的四元数
parent物体父物体的Transform组件
root物体最高层次父物体的Transform

常用方法

void Translate(Vector3 translation)使当前对象位于translation
void Rotate(Vector3 eulerAngles)按给定的欧拉角进行旋转
void RotateAround(Vector3 point, Vector3 axis, float angle) 绕point点沿axis轴旋转angle度
Transform Find(string name)通过名字查找子物体
void LookAt(Transform target)使物体朝向target点
原文地址:https://www.cnblogs.com/AlinaL/p/12852160.html