纳金网

标题: [脚本章节]Overview: Common Operations 常用操作 [打印本页]

作者: 驰骋的风    时间: 2012-10-11 10:15
标题: [脚本章节]Overview: Common Operations 常用操作
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 常用操作





欢迎光临 纳金网 (http://wwww.narkii.com/club/) Powered by Discuz! X2.5