unity

スクリプト

■Update () ■FixedUpdate() Update 同様ゲーム画面が更新されたときに実行されます。但し、Update と違い、フレーム間の時間は処理の重さにかかわらず常に一定です。 Rigidbodyなど物理演算を使用する命令の場合はこちらを使用することが 一般的です。 ■Awak…

キャメラマン カメラ 移動

function Update () { transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); } これをカメラにセットしたら「カメラが」動く.

keycode キーボード入力 unity

http://unity3d.com/support/documentation/ScriptReference/KeyCode.html

回転 GUI シーン切り替え

var playerObj : GameObject; var aTexture : Texture; function OnGUI () { var pivotPoint : Vector2 = Vector2(35, 35); var angleY : float = playerObj.transform.localEulerAngles.y; GUIUtility.RotateAroundPivot(angleY, pivotPoint); GUI.DrawText…

シーン 切り替え

Application.LoadLevel(“名前”)Outputするときは使用するシーン全てを出力する必要があり、 file>build settingsでシーンを登録。ID=0のものが最初に読み込まれる.

unity hit trigger

衝突して吹っ飛ぶ時 void OnCollisionEnter(Collision other) { ... } void OnCollisionStay(Collision other) { ... } void OnCollisionExit(Collision other) { ... } アイテムなど、フラグだけ取りたい時 void OnTriggerEnter(Collision other) { ... } v…

アニメーション

split animation http://gp-portal.jp/material/refMaterial/2255_Unity_document01.pdf function Awake () { animation.Play("run"); } function Update () { if(Input.GetButtonDown ("Fire2")) //マウス右クリックあるいは ALT キー { SendMessage ("Dida…

衝突してきたオブジェクト名

function OnCollisionEnter(theCollision : Collision){ if(theCollision.gameObject.name == "Floor"){ Debug.Log("床に落ちました"); } } function OnCollisionEnter(coll : Collision) { var obj = coll.gameObject; Debug.Log (obj.name); if (obj.name …

チュートリアル unity3dstudent

Beginner/Essentialsのチュートリアルを見ている。 思い出しやすいように、以下に各章の内容をメモする。 Intermediate I01 – Raycasting function Update () { var up = transform.TransformDirection(Vector3.up); var hit : RaycastHit; Debug.DrawRay(tr…

unity3d destructor デストラクタ

function OnDisable(){ Debug.Log('dtor!'); } OnEnable This function is called when the object becomes enabled and active. OnDisable This function is called when the behaviour becomes disabled () or inactive. http://unity3d.com/support/docum…

unity3d material set マテリアル 動的に変更

var theMaterial : Material; ... renderer.material = theMaterial;

unity3d スケーリング scaling scale

transform.localScale = Vector3(2,2,2);

rigidbody.AddForce

unity2.xのときはrigidbody.AddForce(0,10,0)の形式でしたが、 3.xではベクトルを入力するようです。It works! using UnityEngine; using System.Collections; public class PlayerBehaviour : MonoBehaviour { // Use this for initialization void Start (…