- 最后登录
- 2021-9-15
- 注册时间
- 2011-7-15
- 阅读权限
- 100
- 积分
- 50625
- 纳金币
- 53202
- 精华
- 32
|
Overview: Common Operations 常用操作
Most game object manipulations are done either through the game object's Transform and/or Rigidbody. These are accessible inside behaviour scripts through the member variables transform and rigidbody respectively. So if you wanted to rotate an object 5 degrees around its Y axis every frame you could write the following:
很多对游戏对象的操作都是通过修改游戏物体的 Transform (转换)和/或 Rigidbody (刚体).这通过修改脚本里的成员变量transform和rigidbody很容易去实现.如果你想要物体每帧在Y轴上旋转5度,你可以这样写:
C#
JavaScript
using UnityEngine;using System.Collections;public class example : MonoBehaviour {void Update() {transform.Rotate(0, 5, 0);}}
function Update() {transform.Rotate(0, 5, 0);}
If you want to move an object forward you would write this:
如果你想向前移动你的物体,你可以这样写:
C#
JavaScript
using UnityEngine;using System.Collections;public class example : MonoBehaviour {void Update() {transform.Translate(0, 0, 2);}}
function Update() {transform.Translate(0, 0, 2);}
来源:unity3d圣典 更多3D分享尽在web3D纳金网http://www.narkii.com/
————————————————————————————
Subsections 章节
[脚本章节]Scripting Overview 脚本概述
[脚本章节]Overview: Script compilation 脚本编译(高级)
[脚本章节]Overview: Performance Optimization 性能优化
[脚本章节]Overview: The most important classes 重要的类
[脚本章节]Overview : Writing Scripts in C# 使用C#书写脚本
[脚本章节]Overview: Coroutines & Yield 协同程序 & 中断
[脚本章节]Overview: Instantiate 实例
[脚本章节]Overview: Member Variables & Global Variables 成员变量 & 全局变量
[脚本章节]Overview: Vectors 向量
[脚本章节]Overview: Accessing Other Game Objects 访问其他游戏物体
[脚本章节]Overview: Accessing Other Components 访问其他组件
[脚本章节]Overview: Keeping Track of Time 记录时间
[脚本章节]Overview: Common Operations 常用操作
|
|