unity
function Start () { for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent(Rigidbody); cube.transform.position = Vector3 (x, y, 0); } } } //add it to GameObj…
function OnMouseEnter () { renderer.material.color = Color.red; } //attach this script to cube or so.
// Moves all transform children 10 units upwards! for (var child : Transform in transform) { child.Translate(0, 10, 0); } //他オブジェクトとのやり取り //http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Ob…
Tagsを展開してElementに書く。
ビルなど、動かないものはStaticにチェックしておくと オクルージョンカリングによりパフォーマンスが上がるhttp://unity3d.com/support/documentation/Components/class-GameObject.html
GetComponent / SendMessage
//数字が大きい方が動いているときは、そちらが優先して再生される。 function Start () { animation[“idle”].layer = -2; animation["attack01"].layer = 1; }
http://unity3d.com/support/documentation/ScriptReference/GameObject.SendMessage.html // Calls the function ApplyDamage with a value of 5 gameObject.SendMessage ("ApplyDamage", 5.0); // Every script attached to the game object // that has a…
アセット(プレハブやシーン)を右クリック>export package マテリアルでテクスチャを貼ったのなども反映されるので Unityコミュニティの人たちで共有するには良い形式
Application.CaptureScreenshot()
Camera.main.ScreenPointToRay(Input.mousePosition);
file > build settings リスト内にプロジェクトタブからシーンファイルをドラッグアンドドロップ
武器(名前はCylinder)の子にヒット用オブジェクトを加えればOK.Blenderの方で透明な領域を加えておいてもいいけれど、 Unityから追加したほうが試行錯誤できそう。
split animation設定時などでループ再生やピンポン再生をしていできる。 ピンポン再生とは、順再生、逆再生と行うことである。
Blenderで 右パンチ、左パンチ、右キック、左キック のアニメーションを各60フレームで作り、 それらのアニメーションが連続して入ったFBXファイルを Unityにインポート。 Unity側で Inspector > FXXImporter > Split Animationsから フレームの範囲と名前を…
blenderでアニメーションを付けてunityへ。 unityでゲームを実行するとアニメーションが自動実行される。 (動かないようにもunity側で管理できる) しかしループされなかったのでAnimation Wrap ModeをLoopにしたらループした。 これで敵の待機モーションなど…
blenderでrig, animation, fbx export -> unity3dで再生まで完了。 TODO : アニメーションループ TODO : もう1度復習 TODO : モデルをちゃんと作る TODO : テクスチャも TODO : NormalMapも
Input.GetKeyDown http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html KeyCode http://unity3d.com/support/documentation/ScriptReference/KeyCode.html
http://blog.livedoor.jp/akinow/archives/52183427.html 衝突した相手オブジェクトにダメージを与える OnTriggerEnter()文中でHitしたオブジェクトのCollider情報が検出できるわけです。 var damage:int=100; function OnTriggerEnter( otherObject: Collid…
http://d.hatena.ne.jp/ousttrue/searchdiary?word=%2A%5BBlender%5D からの http://sourceforge.jp/projects/meshio/wiki/FrontPage で meshio-blender25 (pymeshio-1.8.6.zip) をDLして配置。 Readmeを見てチェックを入れたらImportできた。 テクスチャの…
Movie Playback is only possible with Unity Pro.だってさー! ;_;
平行投影のゲームも作れる! 右上のギズモをShift+クリックでIso Viewになる。 タクティクスオウガのように、遠いキャラも同じ大きさに見えるようになる。 ゲームのProjectionをそのようにしたければ、 カメラのProjectionをOrthographicにすればよい。
赤い球に入った敵AIだけを有効にする工夫。 カメラに見えないオブジェクトをunableにするOnBecameVisibleもあるけれど、 http://www.cis.sojo-u.ac.jp/~izumi/Unity_Documentation_jp/Documentation/ScriptReference/index.Performance_Optimization.html 背…
//from ScriptB scriptA = GetComponent("ScriptA");
■子や親を探す 子や親のオブジェクトをゲームオブジェクトのTransformコンポーネントから探せる // Find the child "Hand" ofthe game object // we attached the script to transform.Find("Hand").Translate(0,1, 0); ■関数 transformを階層から発見したら…
function Update () { otherScript = GetComponent(OtherScript); otherScript.DoSomething(); } 次のスクリプトとOtherScriptを、同じゲームオブジェクトに付加してくださいこうやって必要な関数だけをオブジェクトに追加していける! http://www.cis.sojo-…
レースゲームとかに使えるね! 昔のアーケードレースゲームの時点で、 ハンドルを少しだけ切ったら微妙に動いて、 ハンドルを大きく切ったら大きく動く工夫がされていました。 入力と、物体を動かす力が線形ではなく、二次関数の方がよい。 ヒント:方向ベク…
回転する箱からビームが出ていて、Player(YOU)がジャンプでよけるゲーム。 ビームに当たるとYOUは血(パーティクル)を吐く。 ビームと同じ方向にRayを発射することでヒットを取っている。 Playerのスクリプト(血パーティクルは事前にPrefabにしてから登録) va…
function OnGUI () { if (GUI.Button (Rect (10,10,150,100), "I am a button")) { print ("You clicked the button!"); } create emptyしたものにこのスクリプトをドラッグすれば表示されます。 function OnGUI () { if (GUI.Button (Rect (10,10,100,50), …
yield WaitForSeconds(5.0);var spawnOBJ : GameObject; private var busy = false; //プライベート変数はこのスクリプト内でのみ参照できる変数で、インスペクター上でも表示されません function DoSpawn () { if (!busy){ busy = true; yield WaitForSecon…