<commit_before>#+TITLE: 2D UFO

* Table of Contents :TOC_1_gh:
 - [[#introduction-to-2d-ufo-project][Introduction to 2D UFO Project]]
 - [[#setting-up-the-play-field][Setting Up The Play Field]]
 - [[#controlling-the-player][Controlling the Player]]
 - [[#adding-collision][Adding Collision]]

* Introduction to 2D UFO Project
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/introduction-2d-ufo-project?playlist=25844

[[file:img/screenshot_2017-04-25_00-55-14.png]]

[[file:img/screenshot_2017-04-25_00-55-53.png]]

[[file:img/screenshot_2017-04-25_00-56-49.png]]

[[file:img/screenshot_2017-04-25_00-57-08.png]]

[[file:img/screenshot_2017-04-25_00-57-45.png]]

* Setting Up The Play Field
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/setting-play-field?playlist=25844

[[file:img/screenshot_2017-04-25_01-11-53.png]]

[[file:img/screenshot_2017-04-25_01-12-27.png]]

[[file:img/screenshot_2017-04-25_01-16-17.png]]

[[file:img/screenshot_2017-04-25_01-17-29.png]]

The layer at bottom(Player, in this case) are rendered last

[[file:img/screenshot_2017-04-25_01-19-45.png]]

[[file:img/screenshot_2017-04-25_01-19-54.png]]


[[file:img/screenshot_2017-04-25_01-20-50.png]]

[[file:img/screenshot_2017-04-25_01-25-27.png]] 

[[file:img/screenshot_2017-04-25_01-26-59.png]]

* Controlling the Player
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/controlling-player?playlist=25844

[[file:img/screenshot_2017-04-27_08-31-38.png]]

Keep the file name and class name consistent.

[[file:img/screenshot_2017-04-27_08-37-31.png]]

#+BEGIN_SRC csharp
  using UnityEngine;
  using System.Collections;

  public class PlayerController : MonoBehaviour {

      public float speed;

      private Rigidbody2D rb2d;

      void Start()
      {
          rb2d = GetComponent<Rigidbody2D> ();
      }

      void FixedUpdate()
      {
          float moveHorizontal = Input.GetAxis ("Horizontal");
          float moveVertical = Input.GetAxis ("Vertical");
          Vector2 movement = new Vector2 (moveHorizontal, moveVertical);
          rb2d.AddForce (movement * speed);
      }
  }
#+END_SRC

* Adding Collision
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/adding-collision?playlist=25844

k
[[file:img/screenshot_2017-04-28_08-31-02.png]]

[[file:img/screenshot_2017-04-28_08-32-37.png]]

[[file:img/screenshot_2017-04-28_08-33-13.png]]

[[file:img/screenshot_2017-04-28_08-34-56.png]]

[[file:img/screenshot_2017-04-28_08-36-50.png]]

[[file:img/screenshot_2017-04-28_08-37-09.png]]

[[file:img/screenshot_2017-04-28_08-38-22.png]]

Box colliders we added overlap each other,
but doesn't collide because they don't have any riigd body.
<commit_msg>Finish following camera in 2d-ufo<commit_after>#+TITLE: 2D UFO

* Table of Contents :TOC_1_gh:
 - [[#introduction-to-2d-ufo-project][Introduction to 2D UFO Project]]
 - [[#setting-up-the-play-field][Setting Up The Play Field]]
 - [[#controlling-the-player][Controlling the Player]]
 - [[#adding-collision][Adding Collision]]
 - [[#following-the-player-with-the-camera][Following the Player with the Camera]]
 - [[#creating-collectable-objects][Creating Collectable Objects]]

* Introduction to 2D UFO Project
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/introduction-2d-ufo-project?playlist=25844

[[file:img/screenshot_2017-04-25_00-55-14.png]]

[[file:img/screenshot_2017-04-25_00-55-53.png]]

[[file:img/screenshot_2017-04-25_00-56-49.png]]

[[file:img/screenshot_2017-04-25_00-57-08.png]]

[[file:img/screenshot_2017-04-25_00-57-45.png]]

* Setting Up The Play Field
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/setting-play-field?playlist=25844

[[file:img/screenshot_2017-04-25_01-11-53.png]]

[[file:img/screenshot_2017-04-25_01-12-27.png]]

[[file:img/screenshot_2017-04-25_01-16-17.png]]

[[file:img/screenshot_2017-04-25_01-17-29.png]]

The layer at bottom(Player, in this case) are rendered last

[[file:img/screenshot_2017-04-25_01-19-45.png]]

[[file:img/screenshot_2017-04-25_01-19-54.png]]


[[file:img/screenshot_2017-04-25_01-20-50.png]]

[[file:img/screenshot_2017-04-25_01-25-27.png]]

[[file:img/screenshot_2017-04-25_01-26-59.png]]

* Controlling the Player
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/controlling-player?playlist=25844

[[file:img/screenshot_2017-04-27_08-31-38.png]]

Keep the file name and class name consistent.

[[file:img/screenshot_2017-04-27_08-37-31.png]]

#+BEGIN_SRC csharp
  using UnityEngine;
  using System.Collections;

  public class PlayerController : MonoBehaviour {

      public float speed;

      private Rigidbody2D rb2d;

      void Start()
      {
          rb2d = GetComponent<Rigidbody2D> ();
      }

      void FixedUpdate()
      {
          float moveHorizontal = Input.GetAxis ("Horizontal");
          float moveVertical = Input.GetAxis ("Vertical");
          Vector2 movement = new Vector2 (moveHorizontal, moveVertical);
          rb2d.AddForce (movement * speed);
      }
  }
#+END_SRC

* Adding Collision
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/adding-collision?playlist=25844

k
[[file:img/screenshot_2017-04-28_08-31-02.png]]

[[file:img/screenshot_2017-04-28_08-32-37.png]]

[[file:img/screenshot_2017-04-28_08-33-13.png]]

[[file:img/screenshot_2017-04-28_08-34-56.png]]

[[file:img/screenshot_2017-04-28_08-36-50.png]]

[[file:img/screenshot_2017-04-28_08-37-09.png]]

[[file:img/screenshot_2017-04-28_08-38-22.png]]

Box colliders we added overlap each other,
but doesn't collide because they don't have any riigd body.

* Following the Player with the Camera
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera?playlist=25844

[[file:img/screenshot_2017-04-28_08-42-40.png]]

While the Player Game Object rotates,
the Camera Object, a child of Player, also rotates.

[[file:img/screenshot_2017-04-28_08-44-24.png]]

#+BEGIN_SRC csharp
  using UnityEngine;
  using System.Collections;

  public class CameraController : MonoBehaviour {

      public GameObject player;
      private Vector3 offset;

      void Start ()
      {
          offset = transform.position - player.transform.position;
      }

      // LateUpdate is called after Update each frame
      void LateUpdate ()
      {
          transform.position = player.transform.position + offset;
      }
  }
#+END_SRC

* TODO Creating Collectable Objects
- https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/creating-collectable-objects?playlist=25844

{'fraction_non_alphanumeric': 0.14981617647058823, 'fraction_numerical': 0.11795343137254902, 'mean_word_length': 4.026173979984604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6508039', 'n_tokens_mistral': 2982, 'n_tokens_neox': 2483, 'n_words': 356}