Windows版Unity5.5.4(パーソナル版,64bit)でC#スクリプトを作成したいのですが
どんなC#スクリプトでも作成した時点で
「No MonoBehaviour scripts
in the file or their names
do not match the file name」
というエラーが出ます
ファイル名とは一致しているので
エクスプローラーのファイル検索で
「MonoBehaviour」と検索しましたが
見つかりませんでした
なので
MonoBehaviourとその関連プログラムのみ
ダウンロードしたいのですが
「MonoBehaviour ダウンロード」と検索しても
それらしいページが見当たらないので
ここで質問させていただきました
~補足~
C#
1※Visual Studio 2015を使用しています 2using UnityEngine; 3 4 5using System.Collections; 6 7 8 9public class NejikoController : 10 11MonoBehaviour 12{ 13 const int MinLane = -2; 14 const int MaxLane = 2; 15 const float LaneWidth = 1.0f; 16 17 18 CharacterController controller; 19 20 21 Animator animator; 22 23 24 25 Vector3 moveDirection = Vector3.zero; 26 int targetLane; 27 28 29 30 public float gravity; 31 32 public float speedZ; 33 34 public float speedX; 35 36 public float speedJump; 37 38 public float accelerationZ; 39 40 41 // Use this for initialization 42 43 44 void Start() 45 { 46 47 48 controller = GetComponent<CharacterController>(); 49 50 51 animator = GetComponent<Animator>(); 52 53 54 55 } 56 57 // Update is called once per frame 58 59 60 void Update() 61 { 62 63 if (Input.GetKeyDown("left")) MoveToLeft(); 64 if (Input.GetKeyDown("right")) MoveToRight(); 65 if (Input.GetKeyDown("space")) Jump(); 66 67 float acceleratiedZ = moveDirection.z + (accelerationZ * Time.deltaTime); 68 moveDirection.z = Mathf.Clamp(accelerationZ, 0, speedZ); 69 70 71 float ratioX = (targetLane * LaneWidth - transform.position.x) / LaneWidth; 72 moveDirection.x = ratioX * speedX; 73 74 75 76 77 if (controller.isGrounded) 78 { 79 80 81 if (Input.GetAxis("Vertical") > 0.0f) 82 { 83 84 85 moveDirection.z = Input.GetAxis("Vertical") * speedZ; 86 87 88 } 89 90 91 92 else 93 { 94 95 96 moveDirection.z = 0; 97 } 98 99 100 transform.Rotate(0, Input.GetAxis("Horizontal") * 3, 0); 101 102 103 104 if (Input.GetButton("Jump")) 105 { 106 107 108 moveDirection.y = speedJump; 109 110 111 animator.SetTrigger("jump"); 112 113 114 } 115 116 117 118 } 119 120 121 122 moveDirection.y -= gravity * Time.deltaTime; 123 124 125 126 Vector3 globalDirection = transform.TransformDirection(moveDirection); 127 128 129 controller.Move(globalDirection * Time.deltaTime); 130 131 132 133 if (controller.isGrounded) 134 135 moveDirection.y = 0; 136 137 138 139 animator.SetBool("run", moveDirection.z > 0.0f); 140 141 142 } 143 public void MoveToLeft() 144 { 145 if (controller.isGrounded && targetLane > MinLane) targetLane--; 146 147 } 148 149 public void MoveToRight() 150 { 151 if (controller.isGrounded && targetLane > MaxLane) targetLane++; 152 153 } 154 155 156 public void Jump() 157 { 158 if (controller.isGrounded) 159 { 160 moveDirection.y = speedJump; 161 animator.SetTrigger("jump"); 162 } 163 164 } 165 166 167 168 169 170} 171
回答1件
あなたの回答
tips
プレビュー