Please Show me my error or a new way to do it
Hi everyone ,
I am in a really bad situation , i am trying to do scenerio mode for my game and it is clone of volfied however i am really stucked.
I show you what i have done till today:
firstly i have create meshes like this:
void CircuitMeshCreate(int i,int textureBorderX){
GameObject circuit = new GameObject ("Circuit "+ i, typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshCollider));
circuit.transform.position = dotVectors [i];
Vector3[] vertices = {
new Vector3 (0, 0),
new Vector3 (1, 0),
new Vector3 (1, 1),
new Vector3 (0, 1)
};
int[] triangles = {
0,3,1,
2,1,3
};
Vector3[] normals = {
new Vector3(0,0,1),
new Vector3(0,0,1),
new Vector3(0,0,1),
new Vector3(0,0,1)
};
int j = Mathf.FloorToInt(i / textureBorderX);
int xx = Mathf.FloorToInt(i / textureBorderX);
Vector2[] uvs = {
new Vector2 ( (float)xx / textureBorderX, (float)(i - (j * textureBorderX)) / textureBorderX),
new Vector2 ( (float)(xx + 1) / textureBorderX, (float)(i - (j * textureBorderX)) / textureBorderX),
new Vector2 ( (float)(xx + 1) / textureBorderX, (float)(i - (j * textureBorderX) + 1) / textureBorderX),
new Vector2 ( (float)xx / textureBorderX, (float)(i - (j * textureBorderX) + 1) / textureBorderX)
};
Mesh mesh = new Mesh ();
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.normals = normals;
mesh.uv = uvs;
MeshFilter m_Filter = circuit.transform.GetComponent<MeshFilter> ();
m_Filter.mesh = mesh;
MeshRenderer m_Renderer = circuit.transform.GetComponent<MeshRenderer> ();
m_Renderer.material = material;
circuit.transform.SetParent (this.Meshes.transform);
}
and placed dots to all of those vertices:
for (int i = 0; i < dotVectors.Length; i++) {
GameObject dot = (GameObject)Instantiate (nokta, dotVectors [i], Quaternion.identity);
dot.transform.SetParent (transform);
dot.name = "Nokta" + i;
}
these for detection of location of the player , easily use of line renderer and change the material of background for every crop.
however it didn't go with i want.
i coded every dots ,on the edges , Bool enable = true but the all of others "enable = false" .these for ship can walk on the enables .
else {
if (Input.GetKey (KeyCode.UpArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer + 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y < GameObject.Find ("Nokta" + (noktaIndexer + 1)).transform.position.y) {
if (GameObject.Find ("Nokta" + (noktaIndexer + 1)).GetComponent<Node> ().enable) {
noktaIndexer++;
Debug.Log ("spacesiz döndürdü");
}
}
}
} else if (Input.GetKey (KeyCode.DownArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y > GameObject.Find ("Nokta" + (noktaIndexer - 1)).transform.position.y) {
if (GameObject.Find ("Nokta" + (noktaIndexer - 1)).GetComponent<Node> ().enable) {
noktaIndexer -= 1;
}
}
}
} else if (Input.GetKey (KeyCode.LeftArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x > GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex)).transform.position.x) {
if (GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex)).GetComponent<Node> ().enable) {
noktaIndexer -= ekranIndex;
}
}
}
} else if (Input.GetKey (KeyCode.RightArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x < GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex)).transform.position.x) {
if (GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex)).GetComponent<Node> ().enable) {
noktaIndexer += ekranIndex;
}
}
}
}
}
it was very successul but now chaos starts.
when the player pressed "space" the inside dots must be enable so i firstly try on line renderer:
if (Input.GetKey (KeyCode.Space)) {
if (Changed) {
LineRenderer lR = transform.GetComponent<LineRenderer> ();
if (transform.position.x != GameObject.Find ("Ship-Beta").transform.position.x && transform.position.y != GameObject.Find ("Ship-Beta").transform.position.y ) {
Changed = false;
return;
}
lR.SetPosition (0, transform.position);
lR.SetPosition (1, GameObject.Find ("Ship-Beta").transform.position );
}
}
it's works well however if the player return of a move forexample he pressed 10 up and 5 down WİTH SPACE , line renderer works still 10 up so it was a crush for me and unsolveable.
then i must show you travel with space codes however it was very long so if yo read fo one direction , it is enough to understand to logic but anyway i have copied all of them (textureBordererX = ekranIndex) :
if (Input.GetKey (KeyCode.Space) ) {
//dolsun buralaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrr...
// upppp
//indir
if (Input.GetKeyDown (KeyCode.UpArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer + 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y < GameObject.Find ("Nokta" + (noktaIndexer + 1)).transform.position.y) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
}
//basılı
if (Input.GetKey(KeyCode.UpArrow) ) {
if (Input.GetKeyDown (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
if (GameObject.Find ("Nokta" + (noktaIndexer + 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y < GameObject.Find ("Nokta" + (noktaIndexer + 1)).transform.position.y) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().enable = true;
noktaIndexer++;
}
}
if (Input.GetKeyUp (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (0, -1);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
}
//kaldır
if (Input.GetKeyUp(KeyCode.UpArrow)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (0, -1);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
//Down
//indir
if (Input.GetKeyDown (KeyCode.DownArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y > GameObject.Find ("Nokta" + (noktaIndexer - 1)).transform.position.y) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
}
//Down basılı ve space sıralı
if (Input.GetKey (KeyCode.DownArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - 1))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.y > GameObject.Find ("Nokta" + (noktaIndexer - 1)).transform.position.y) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().enable = true;
noktaIndexer --;
}
}
if (Input.GetKeyUp (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (0, 1);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
if (Input.GetKeyDown (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
//kaldır
if (Input.GetKeyUp(KeyCode.DownArrow)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (0, 1);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
//LEeeeeFT
//İndiiir
if (Input.GetKeyDown (KeyCode.LeftArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x > GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex)).transform.position.x) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
}
//basılı
if (Input.GetKey (KeyCode.LeftArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x > GameObject.Find ("Nokta" + (noktaIndexer - ekranIndex)).transform.position.x) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().enable = true;
noktaIndexer -= ekranIndex;
}
}
if (Input.GetKeyUp (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (-1,0);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
if (Input.GetKeyDown (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
//kaldır
if (Input.GetKeyUp(KeyCode.LeftArrow)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (-1,0);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
//RIıııııiiiiiGHT
//indir
if (Input.GetKeyDown (KeyCode.RightArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x < GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex)).transform.position.x) {
Debug.Log ("ilk nokta düzgün");
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
}
//basılı
if (Input.GetKey (KeyCode.RightArrow)) {
if (GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex))) {
if (GameObject.Find ("Nokta" + noktaIndexer).transform.position.x < GameObject.Find ("Nokta" + (noktaIndexer + ekranIndex)).transform.position.x) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().enable = true;
noktaIndexer += ekranIndex;
}
}
if (Input.GetKeyUp (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (1,0);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
if (Input.GetKeyDown (KeyCode.Space)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
}
}
//kaldır
if (Input.GetKeyUp(KeyCode.RightArrow)) {
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().objeninYönü = new Vector3 (1,0);
GameObject.Find ("Nokta" + (noktaIndexer )).GetComponent<Node> ().Changed = true;
GameObject.Find ("Nokta" + (noktaIndexer)).GetComponent<Node> ().BreakPoint = true;
}
}
im still here and i really crushed i have nothing to do more because i cant generate any solve here so
PLEASE give me a solve or a new idea to start from beginning.
Your answer
Follow this Question
Related Questions
Scaling a Line 0 Answers
Basic Logic makes absolutely no sense [JS] 2 Answers
Script function being applied to everything it's attached to logic error 2 Answers
Randomness based on time passed 2 Answers
Unexpected symbol `currentY Unexpected symbol end-of-file) Unexpected symbol Quaternion') 0 Answers