Unity Transform 学习和应用

Unity3D的Transform类是游戏中物体变换的核心,包括位置(position)、旋转(rotation)和缩放(scale)的控制。每个游戏对象都有一个Transform,用于描述其在场景中的位置、方向和大小。Transform支持对子对象的层级操作,如Translate、Rotate、RotateAround等方法,实现物体的平移、旋转和围绕点旋转。此外,还提供了查找子对象、判断父子关系的功能。
摘要由CSDN通过智能技术生成

Transform类学习

Transform 变换,是场景中最常打交道的类,用于控制物体的位移,旋转,缩放等功能。

Transform
Class, inherits from Component, IEnumerable

Position, rotation and scale of an object.
控制物体的位置,旋转和缩放。

Every object in a scene has a Transform. It’s used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierachically. This is the hierarchy seen in the Hierarchy pane. They also support enumerators so you can loop through children using:
每一个场景中的物体都有Transform这个类,他是用来储存和处理物体的位移,旋转和缩放的。每一个Transform都可以有一个父物体,这可以让你得到下游节点的位移旋转和缩放。这个层次结构关系可以从Hierarchy面板中看到。他还支持enumerators,以使用循环来遍寻所有的子节点。

all transform children 10 units upwards!

for (var child : Transform in transform) {
    child.position += Vector3.up * 10.0;
}

Variables 属性

  • position: Vector3 绝对位置,相对于世界坐标物体的位置。

  • localPosition: Vector3 相对位置,或自身位置,物体相对于父物体的位置。

  • eulerAngles: Vector3 轴向旋转角度,相对于世界坐标轴。单位为,而非弧度。运行时的数值在(0,360)。

  • localEulerAngles: Vector3 相对轴向旋转角度,或自身的旋转角度,物体相对于父物体

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值