From 7d20c12e6823d7e41420b9b21ad3e31603603950 Mon Sep 17 00:00:00 2001 From: Saikyun Date: Mon, 14 May 2018 21:09:16 +0200 Subject: [PATCH 1/4] Update README.md move-forward was missing in the readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 62eef49..87b5fdc 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,13 @@ Now let's define some helper functions for input and math. (Input/GetKey "a") (Input/GetKey "s") (Input/GetKey "d"))) + + +(defn move-forward [^Rigidbody2D rb, distance] + (.MovePosition rb + (v2+ (.position rb) + (v2* (bearing-vector (.rotation rb)) + distance)))) ``` ### Player Movement From 0e52c25e08e80feab5ae943834eb308c51e75a57 Mon Sep 17 00:00:00 2001 From: Saikyun Date: Tue, 15 May 2018 08:21:52 +0200 Subject: [PATCH 2/4] Update README.md The layers were missing as well, so I added them to the readme. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 87b5fdc..e60f1bb 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,15 @@ Now let's define some helper functions for input and math. (.MovePosition rb (v2+ (.position rb) (v2* (bearing-vector (.rotation rb)) - distance)))) +        distance)))) +``` + +We will also make use of layers. Lets define them so that we don't need to look them up more than once. + +``` +(def player-bullets-layer (UnityEngine.LayerMask/NameToLayer "player-bullets")) + +(def enemy-bullets-layer (UnityEngine.LayerMask/NameToLayer "enemy-bullets")) ``` ### Player Movement From c99acfaf8a4cbc1ccc29b4d62a76a16a2b58b7e5 Mon Sep 17 00:00:00 2001 From: Saikyun Date: Tue, 15 May 2018 08:31:28 +0200 Subject: [PATCH 3/4] Update README.md Added a description on how to add layers. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e60f1bb..9700ca2 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Now let's define some helper functions for input and math.        distance)))) ``` -We will also make use of layers. Lets define them so that we don't need to look them up more than once. +We will also make use of layers to manage what bullets can collide with. First add `player-bullets` and `enemy-bullets` as custom layers in Unity. We do that by clicking `Edit -> Project Settings -> Tags and Layers`, then expand `Layers` and add the layers `player-bullets` and `enemy-bullets`. Then lets define them in the code so that we don't need to look them up more than once. ``` (def player-bullets-layer (UnityEngine.LayerMask/NameToLayer "player-bullets")) From 77aeb9bab7fc684cded9fd83b5b0bee0afa0cea4 Mon Sep 17 00:00:00 2001 From: Saikyun Date: Thu, 17 May 2018 15:33:19 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9700ca2..6413b98 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Now let's define some helper functions for input and math.        distance)))) ``` -We will also make use of layers to manage what bullets can collide with. First add `player-bullets` and `enemy-bullets` as custom layers in Unity. We do that by clicking `Edit -> Project Settings -> Tags and Layers`, then expand `Layers` and add the layers `player-bullets` and `enemy-bullets`. Then lets define them in the code so that we don't need to look them up more than once. +We will also make use of layers to manage what bullets can collide with. First add `player`, `enemy`, `player-bullets` and `enemy-bullets` as custom layers in Unity. We do that by clicking `Edit -> Project Settings -> Tags and Layers`, then expand `Layers` and add the layers `player`, `enemy`, `player-bullets` and `enemy-bullets`. Then lets define them in the code so that we don't need to look them up more than once. ``` (def player-bullets-layer (UnityEngine.LayerMask/NameToLayer "player-bullets")) @@ -154,6 +154,8 @@ We will also make use of layers to manage what bullets can collide with. First a (def enemy-bullets-layer (UnityEngine.LayerMask/NameToLayer "enemy-bullets")) ``` +After that we have to define which layers collides with which. To do that we go to `Edit -> Project Settings -> Physics 2D`, and under `Layer Expansion Matrix` we deselect the collisions between `enemy` and `enemy-bullets`, and between `player` and `player-bullets`. Now all the layers are ready! + ### Player Movement Now we can write the interactive movement logic.