前提・実現したいこと
キャラクターをキーボード入力で操作できるようにしたい。
発生している問題・エラーメッセージ
Unexpected symbol '!' Unexpected symbol '=' Unexpected symbol 'else' 37、41行目です。
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class ChihiroAnimation : UnityEngine.MonoBehaviour 6{ 7 8 private Animator animator; 9 10 private const string isRun = "isRun"; 11 private const string isJump = "isJump"; 12 13 private float movement = 20f; 14 private float moveX = 0f; 15 private float moveZ = 0f; 16 17 void Start () 18 { 19 this.animator = GetComponent<Animator>(); 20 } 21 22 void Update() 23 { 24 var cameraForward = 25 Vector3.Scale( 26 Camera.main.transform.forward, new Vector3(1, 0, 1) 27 ).normalized; 28 var vertial = cameraForward * Input.GetAxis("Vertial"); 29 var horizontal = Camera.main.transform.right * Input. 30 GetAxis("Horizontal"); 31 var direction = vertial + horizontal; 32 33 moveX = direction.x * Time.deltaTime * movement; 34 moveZ = direction.z * Time.deltaTime * movement; 35 transform.Translate(moveX, 0f, moveZ, Space.World); 36 37 if (moveX ! = 0 || moveZ ! = 0) 38 { 39 transform.rotation = Quaternion.LookRotation(direction); 40 this.animator.SetBool(isRun, true); 41 } 42 else 43 { 44 this.animator.SetBool(isRun, false); 45 } 46 if (Input.GetKey(KeyCode.Space)) 47 { 48 this.animator.SetBool(isJump, true); 49 } 50 else 51 { 52 this.animator.SetBool(isJump, false); 53 } 54 } 55} 56
試したこと
}を入れてみたりしました。
補足情報(FW/ツールのバージョンなど)
MagicaVoxelでつくった3Dモデルを動かそうとしています。
追記です
この投稿をしてUnityにもどったらエラーが増えていまた。
如何せん初心者でして何が間違えているのか全くわからないので、このサイトの意図している質問ではなくなってしまうかも知れませんが、どこが間違えているか、そしてどう直せば良いか教えて頂けたら幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/09/23 08:46