unity C# エラーで実行できない
解決済
回答 1
投稿 ・編集
- 評価
- クリップ 0
- VIEW 1,956
unity&C#初心者です。エラーが出てどこがおかしいのかわかりません。教えてください。
エラーは一番最後の空白のところ(79,9)となっていますがどういうことなのでしょうか?
using UnityEngine;
using System.Collections;
public class PlayerSCR : MonoBehaviour {
public bool moveFlag;
public bool sceneJumpFlag = false;
// Use this for initialization
void Start () {
iTween.Init (gameObject);
}
// Update is called once per frame
void Update () {
Move ();
}
void Move() {
if (moveFlag) return;
Vector2 move;
move.x = Input.GetAxisRaw ("Horizontal");
move.y = Input.GetAxisRaw ("Vertical") ;
if( Input.GetKey( "x" ) ) {
Debug.Log( "Input X Key" );
if (move.x != 0 && move.y != 0) {
HitCheck(move);
SetMove(move);
}
} else {
if (move.x != 0 || move.y != 0) {
HitCheck(move);
SetMove(move);
}
}
}
void HitCheck (Vector2 move){
RaycastHit2D hit = new RaycastHit2D ();
Vector2 tmpStartPoint = this.gameObject.transform.position;
Vector2 tmpDirection = move;
float tmpRange = Mathf.Sqrt (Mathf.Abs (move.x) + Mathf.Abs (move.y));
hit = Physics2D.Raycast (tmpStartPoint, tmpDirection, tmpRange);
if (hit) {
if (hit.transform.gameObject.name == "Floor_Step") {
sceneJumpFlag = true;
}
}
}
void SetMove( Vector2 move ) {
Vector3 targetPos = new Vector3 (gameObject.transform.position.x + move.x, gameObject.transform.position.y + move.y, 0.0f);
Hashtable hash = new Hashtable();
hash.Add( "position", targetPos );
hash.Add( "time", 0.5f );
hash.Add( "oncomplete", "OnCompleteCallback");
hash.Add( "oncompleteparams", "MoveComplete");
hash.Add( "oncompletetarget", gameObject );
iTween.MoveTo (gameObject, hash );
moveFlag = true;
}
// iTween Complete
void OnCompleteCallback( string message ){
moveFlag = false;
Debug.Log( message );
if (sceneJumpFlag) {
switch (Application.loadedLevelName) {
case "_town":
Application.LoadLevel ("_dungeon");
break;
case "_dungeon":
Application.LoadLevel ("_town");
break;
}
}
}
エラーは一番最後の空白のところ(79,9)となっていますがどういうことなのでしょうか?
using UnityEngine;
using System.Collections;
public class PlayerSCR : MonoBehaviour {
public bool moveFlag;
public bool sceneJumpFlag = false;
// Use this for initialization
void Start () {
iTween.Init (gameObject);
}
// Update is called once per frame
void Update () {
Move ();
}
void Move() {
if (moveFlag) return;
Vector2 move;
move.x = Input.GetAxisRaw ("Horizontal");
move.y = Input.GetAxisRaw ("Vertical") ;
if( Input.GetKey( "x" ) ) {
Debug.Log( "Input X Key" );
if (move.x != 0 && move.y != 0) {
HitCheck(move);
SetMove(move);
}
} else {
if (move.x != 0 || move.y != 0) {
HitCheck(move);
SetMove(move);
}
}
}
void HitCheck (Vector2 move){
RaycastHit2D hit = new RaycastHit2D ();
Vector2 tmpStartPoint = this.gameObject.transform.position;
Vector2 tmpDirection = move;
float tmpRange = Mathf.Sqrt (Mathf.Abs (move.x) + Mathf.Abs (move.y));
hit = Physics2D.Raycast (tmpStartPoint, tmpDirection, tmpRange);
if (hit) {
if (hit.transform.gameObject.name == "Floor_Step") {
sceneJumpFlag = true;
}
}
}
void SetMove( Vector2 move ) {
Vector3 targetPos = new Vector3 (gameObject.transform.position.x + move.x, gameObject.transform.position.y + move.y, 0.0f);
Hashtable hash = new Hashtable();
hash.Add( "position", targetPos );
hash.Add( "time", 0.5f );
hash.Add( "oncomplete", "OnCompleteCallback");
hash.Add( "oncompleteparams", "MoveComplete");
hash.Add( "oncompletetarget", gameObject );
iTween.MoveTo (gameObject, hash );
moveFlag = true;
}
// iTween Complete
void OnCompleteCallback( string message ){
moveFlag = false;
Debug.Log( message );
if (sceneJumpFlag) {
switch (Application.loadedLevelName) {
case "_town":
Application.LoadLevel ("_dungeon");
break;
case "_dungeon":
Application.LoadLevel ("_town");
break;
}
}
}
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 過去に投稿した質問と同じ内容の質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 88.23%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
2014/12/14 20:36
2015/02/12 10:14
対応するかっことじの色が変わります。