-3
hi 私はミニゴルフゲームを始めたい場所がどこにあるのか、ゲームを作りたいと思っています... だから私はexpl。 1を押し、私のボールをexplのために特定のポジションに持って行きます。 〜x 5、y 10、z 15キーボードのプレスでオブジェクトの位置を設定する方法は?
Unity3dでint C#を作成するにはどうすればよいですか?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class testscript : MonoBehaviour {
[SerializeField]
List<KeyCode> keys; //array also acceptable here, but i prefer to use Lists
//for line above, this could also be a List<string> because of the other overload of Input.GetKey but this way is best practice
[SerializeField]
Transform transform;
[SerializeField]
List<Vector3> pos;
void Update(){
for (int i = 0; i < keys.Count; i++) { //not foreach because we will need value of i
if (Input.GetKey (keys [i])) { //this will be continuous, you could also use input.GetKeyDown
//*****************
//DO SOMETHING HERE
//*****************
transform.position = pos[i];
Debug.Log ("Yay! A key was pressed!");
}
}
}
}
そして、あなたはint varname;
を行うかを定義するためにC#でint
を作るために、あなたの2番目の質問に答えるために:ここで
あなたのコードはどこですか? –
これはあなたが尋ねる質問のタイプではありませんstackoverflow – Bijan
まず、このためのコードを記述してください。コーディング中に立ち往生した場合は、ここで質問してその特定の問題に関連するヘルプを得ることができます。 –