|
||||||||||||||||
|
||||||||||||||||
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:
JavaScripts
function Update() {
transform.Rotate(0, 5, 0); }
using UnityEngine;
using System.Collections; public class example : MonoBehaviour { void Update() { transform.Rotate(0, 5, 0); } }
import UnityEngine
import System.Collections class example(MonoBehaviour): def Update(): transform.Rotate(0, 5, 0) If you want to move an object forward you would write this:
JavaScripts
function Update() {
transform.Translate(0, 0, 2); }
using UnityEngine;
using System.Collections; public class example : MonoBehaviour { void Update() { transform.Translate(0, 0, 2); } }
import UnityEngine
import System.Collections class example(MonoBehaviour): def Update(): transform.Translate(0, 0, 2) |
|
|||||||||||||||
|
Ruslan Slobodianiuk © unity3dforge.com все права защищены
|
||||||||||||||||
Полезные ресурсы:
Программа для создания скриншотов