查看: 2117|回复: 0

[脚本章节]Overview: Common Operations 常用操作

[复制链接]

3795

主题

2

听众

5万

积分

版主

Rank: 7Rank: 7Rank: 7

纳金币
53202
精华
32

活跃会员 优秀版主 推广达人 突出贡献 荣誉管理 论坛元老

发表于 2012-10-11 10:15:47 |显示全部楼层
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 常用操作
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-3-29 18:41 , Processed in 0.085997 second(s), 34 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部