using
1 2public class smartballsclipt : MonoBehaviour { 3 float power = 0f; 4 GameObject[] cubes = new GameObject[5]; 5 6 7 8 // Use this for initialization 9 void Start () { 10 11 for(int i = 0; i < 5; i++){ 12 cubes [i] = GameObject.Find ("BoardCube" + i); 13 Vector3 move = cubes[i].transform.position; 14 AnimationClip clip = new AnimationClip (); 15 clip.legacy = true; 16 Keyframe[] keysX = new Keyframe[2]; 17 keysX [0] = new Keyframe (0f, move.x - 3); 18 keysX [1] = new Keyframe (i + 1f, move.x - 3); 19 AnimationCurve curveX = new AnimationCurve (keysX); 20 clip.SetCurve ("", typeof(Transform), "localPosition.x", curveX); 21 clip.wrapMode = WrapMode.PingPong; 22 Keyframe[] keysY = new Keyframe[2]; 23 keysY[0] = new Keyframe(0f, move.y); 24 keysY[1] = new Keyframe(i + 1f ,move.y); 25 AnimationCurve curveY = new AnimationCurve(keysY); 26 clip.SetCurve("", typeof(Transform), "localPosition.y",curveY); 27 Keyframe[] keysZ = new Keyframe[2]; 28 keysZ[0] = new Keyframe(0f, move.z); 29 keysZ[1] = new Keyframe(i + 1f,move.z); 30 AnimationCurve curveZ = new AnimationCurve(keysZ); 31 clip.SetCurve("", typeof(Transform),"localPosition.Z", curveZ); 32 cubes[i].GetComponent<Animation>().AddClip(clip, "clip1"); 33 cubes[i].GetComponent<Animation>().Play("clip1"); 34 } 35 } 36 37 38 // Update is called once per frame 39 void Update () { 40 Rigidbody rigidbody = GetComponent<Rigidbody> (); 41 Renderer renderer = GetComponent<Renderer> (); 42 43 MoveCuve (); 44 rigidbody.AddForce (0f, 0f, -1f); 45 if (Input.Getkey(KeyCode.Space)){ 46 power += 0.01f; 47 if (power > 1f) { 48 power = 1f; 49 } 50 renderer.material.color = new Color(1f,power,0f); 51 } 52 if (Input.GetKeyUp(KeyCode.Space)){ 53 rigidbody.AddForce(new Vector3(0f, 0f, power * 2500f)); 54 power = 0f; 55 renderer.material.color = Color.red; 56 } 57} 58 59void Move(){ 60 for(int i = 0;i <6; i++){ 61 cubes[i].transform.Rotate(new Vector3(0f,2.5f,0f)); 62 } 63} 64} 65 66コード
46行目 MoveCube ();
名前'MoveCube'は現在のコンテキスト内に存在しません。というものと
48行目 if(Input.GetKey(KeyCode.Space)){
UnityEngine.InputにGetKeyの定義がありません
というエラーが起きていますが、原因がわかりません・・・
どのような対処をしたらいいでしょうか? ご回答をお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/29 13:39