# なぎせろりん強化合宿 ## 1日目 - int (整数);←これで締める癖をつける - flout (少数); - bool (真偽); - if (裁判); - else if (ifに引っかからなかった奴を再審); - else (有罪); - for (ループさせる、後ろに(int i = 数; i < 回数; i++)で連続足し算); - void start (最初に決まるとこ); - void update (キャラ動かしたりいっぱい書くとこ); - void OnCollisionEnter (ぶっちゃけ難しくて分からん、多分当たり判定関係); - 超大事基礎中の基礎 〜全ては上から下に〜 ## Unity https://store.unity.com/ja?_ga=2.161484156.150687872.1576238354-161999777.1572278641#plans-individual ## Visual Studio https://visualstudio.microsoft.com/ja/vs/unity-tools/ ## Unity API Documentation https://docs.unity3d.com/ScriptReference/ ## C#入門 ```csharp= int a = 1; a = 2; a = 3; int b = a + 1; a = 4; int c = a + b; c = c + 1; // 上の文と下の文は同じ c++; Debug.Log(a + b); // 足し算 Debug.Log(a - b); // 引き算 Debug.Log(a * b); // 掛け算 Debug.Log(a / b); // 割り算 Debug.Log("Hello"); Debug.Log(a); ``` ```csharp= // HP int enemy_hp = 3; enemy_hp = enemy_hp - 2; // 上の文と下の文は同じ意味 enemy_hp -= 2; if(enemy_hp >= 3) { Debug.Log("生存"); } else if(enemy_hp > 0) { Debug.Log("瀕死"); } else if(enemy_hp > 0) { Debug.Log("瀕死"); } else if(enemy_hp > 0) { Debug.Log("瀕死"); } else { Debug.Log("死亡"); } Debug.Log(enemy_hp); ``` ```csharp= // Max HP int max_hp = 300; // HP int hp = 50; // float a = 2.5; if((float)hp / (float)max_hp * 100 >= 20) { Debug.Log("Event"); } float a = 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; a += 0.1; // ここの条件は満たされない if(a == 1.0) { } ``` ```csharp= // ループ float a = 0.1; for(int i = 0; i < 9; i++) { a += 0.1; } int sum = 0; for(int i = 1; i <= 100; i++) { sum = sum + i; } ``` ```csharp= int a = 1; ``` - AIUEO - KAKIKUKEKO ## Unityスクリプト ```csharp= void Start() { } void Update() { Rigidbody2D rb2d = GetComponent<Rigidbody2D>(); if(Input.GetKey(KeyCode.LeftArrow)) { Debug.Log("Left was pressed"); rb2d.AddForce(transform.left * 100); } } ``` ### 当たり判定 https://qiita.com/moscoara_nico/items/8eee1de552601a8a8f1f ```csharp= // 当たり判定 void OnCollisionEnter(Collision collision) { ground = true; Debug.Log("Hit"); // ログを表示する } ``` ```csharp= using UnityEngine.SceneManagement; // シーン切り替え SceneManager.LoadScene("SceneName"); ``` ### 画像反転 ```csharp= Vector3 scale = transform.localScale; scale.x *= -1; transform.localScale = scale; ``` ### 親削除 ```cshapr= Destroy(transform.root.gameObject); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up