前提・実現したいこと
unityでブロック崩しを作成しています。
ブロックがすべて消えたら別に作成したgameclearスクリプトを実行してクリア画面に移動したいです
発生している問題・エラーメッセージ
Assets/ball.cs(25,4): error CS1525: Unexpected symbol `void'
該当のソースコード
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ball : MonoBehaviour
{
public GameObject gameClear;
public int blockCt = 20;
Rigidbody rb;
Vector3 v;
// Use this for initialization
void Start()
{
//以下を追加
this.GetComponent<Rigidbody>().AddForce(
(transform.forward + transform.right) * speed,
ForceMode.VelocityChange);
rb = GetComponent<Rigidbody>();
rb.AddForce((transform.up + transform.right) * speed, ForceMode.VelocityChange);
}
}
// Update is called once per frame
void Update()
{
//ブロックを全て壊した時
if (blockCt == 0)
{
//ボールの動きを止める
GetComponent<Rigidbody>().velocity = Vector3.zero;
//GameClearScriptのWinメソッドを実行しGameClearの文字を表示
GameClear.SendMessage("Win");
//クリックしてタイトル画面へ
if (Input.GetMouseButtonDown(0))
{
SceneManager.LoadScene("start");
}
}
}
void OnCollisionEnter(Collision col)
{
//ブロックにぶつかるとブロックカウント-1
if (col.gameObject.tag == "block")
{
blockCt -= 1;
}
}
}
}
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/18 13:07