連打レース:スクラッチ版&UNITY版
![](https://digilab.tech/materials/wp-content/uploads/2019/09/連打ゲーム_スクラッチ_UNITY-1.png)
連打レースゲームはスクラッチとUNITYで作っていきます。スクラッチ版で基本的なしくみを理解したら、UNITYで3Dゲームにしてみましょう。
スクラッチ版「連打レース」
![](https://digilab.tech/materials/wp-content/uploads/2019/09/P1-Renda-01.png)
スクラッチ版連打レースゲームを作ろう!!
![](https://digilab.tech/materials/wp-content/uploads/2019/09/ゲーム説明.gif)
![](https://digilab.tech/materials/wp-content/uploads/2019/09/Renda-03.png)
まずキャラクター1のプログラミングをしましょう!
キャラクター2は「a」と「s」で動くようにしよう!
勝ったキャラクターを表示する、勝ちスプライトをつくろう!
「ネコが勝ち」スプライトに↓のプログラムをかこう!
「人が勝ち」スプライトに↓のプログラムをかこう!
次にゴールのテープ(スプライト)をつくろう!!
UNITY版「連打レース」
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-04-15.01.29.png)
1.まず簡単な自分の町とレース用の道をつくろう!
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.04.40-1024x529.png)
2.車などの競争するプレイヤーをおこう
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.01.00.png)
下のプログラムを書きます。
3.車を動かすためのプログラムをかこう
新しいスクリプトファイルを作成します
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.12.09.png)
重要:ファイル名をすぐにつけます。
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.15.26.png)
下のプログラムを書きます。
4.二人でやるゲームなのでもう一つの車も同じようにボタンで進むようにしよう。
5.ゴール(オブジェクト)を作ろう
このゴールオブジェクトにあたったプレイヤーの名前を表示する
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.30.27.png)
まずはじめにCubeで作り↑のように形を変えます
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.36.08.png)
色を透明にする
オブジェクトに色をつけるにはマテリアルが必要です。
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.40.25.png)
マテリアルの設定を下のようにすると透明になる
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.42.52.png)
6.勝ったプレイヤー名を表示するTEXTオブジェクトをつくろう
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.47.08.png)
TEXTオブジェクトの名前をWinnerに変えます。
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.52.13.png)
テキスト文の中を全部けします。
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-13-14.56.17.png)
8.勝者の名前を表示するTEXTオブジェクトをつくる
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-19-13.44.12.png)
つくたTEXTオブジェクトの名前を「Winner」にする
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-19-13.58.17.png)
GoleCubeにアタッチしたGameControllerスクリプトのWinner変数にTextオブジェクト(Winner)をアタッチする。
![](https://digilab.tech/materials/wp-content/uploads/2019/09/スクリーンショット-2019-09-19-13.46.02.png)
これで完成だ。思い通りに動くかテストしてみよう!!