# Help With Game

**URL:** https://discussions.unity.com/t/help-with-game/594701
**Category:** Scripting
**Tags:** Scripting
**Created:** [August 23, 2015, 8:21pm UTC](https://discussions.unity.com/t/help-with-game/594701 "2015-08-23T20:21:05Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Cat\_cop](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Cat\_cop](https://discussions.unity.com/u/Cat_cop)
#### Post date: [August 23, 2015, 8:21pm UTC](https://discussions.unity.com/t/help-with-game/594701/1 "2015-08-23T20:21:05Z")

</div>

Hello Everyone,  
I am making a video game, and I am currently working on a 3D wave and I am using a BSplineSurface.cs script file and it is giving me a parsing error and I don’t know what to do.  
Here are the details.  
It originally had 148 lines. Now it has 418.

```auto
using UnityEngine;

using System.Collections;

using System.Collections.Generic;

public class BSplineSurface {

  /*

9. * THESE VALUES MUST BE SET BEFORE CALCULATING

10. */

  //size of the control net (e.g. 3x4 net)

  public int NI = 4; //setting these to high can crash unity

  public int NJ = 4;

  //Grid of control points

  public Vector3[,] controlGrid;

  //The degree in each direction

  public int TI = 3;

  public int TJ = 3;

  //output GRID resolution (e.g. 30x40)

  public int RESOLUTIONI = 150; //setting these to high can crash unity

  public int RESOLUTIONJ = 150;

  //the output Grid

  public Vector3[,] outputGrid;

  /*

26. * INTERNAL VALUES

27. */

  //internal knots in each direction

  private int[] knotsI;

  private int[] knotsJ;

  //internal variables

  private int i, j, ki, kj;

  private float intervalI, incrementI, intervalJ, incrementJ, bi, bj;

  //FUNCTIONS

  private BSplineMath bmath = new BSplineMath();

  //constructor

  public BSplineSurface()

  {

  Init();

  }

  //MUST BE CALLED FIRST

  public void Init () {

  controlGrid = new Vector3[NI+1,NJ+1];

  outputGrid = new Vector3[RESOLUTIONI, RESOLUTIONJ];

  //init step size (the increment steps)

  incrementI = (NI-TI+2) / ((float)RESOLUTIONI - 1);

  incrementJ = (NJ-TJ+2) / ((float)RESOLUTIONJ - 1);

  //Calculate KNOTS

  knotsI = bmath.SplineKnots(NI, TI);

  knotsJ = bmath.SplineKnots(NJ, TJ);

  }

  // Use this for random initialization

  public void InitRandomGrid () {

  //init control points (random z)

  for(i=0; i<=NI; i++)

  {

  for(j=0; j<=NJ; j++)

  {

  controlGrid[i, j].x = i;

  controlGrid[i, j].y = j;

  controlGrid[i, j].z = Random.value;

  }

  }

  }

  // Use this for grid input (remember to set NI and NJ before(the grid size) and call Init)

  public void InitGrid (Vector3[,] inputGrid) {

  //init control points (random z)

  for(i=0; i<=NI; i++)

  {

  for(j=0; j<=NJ; j++)

  {

  controlGrid[i, j] = inputGrid[i, j];

  }

  }

  }

  public void Calculate()

  {

  //MAIN CALCULATIONS

  intervalI = 0;

  for(i = 0; i < RESOLUTIONI-1; i++)

  {

  intervalJ = 0;

  for(j = 0; j < RESOLUTIONJ-1; j++)

  {

  outputGrid[i, j] = Vector3.zero;

  for(ki = 0; ki <= NI; ki++)

  {

  for(kj = 0; kj <= NJ; kj++)

  {

  bi = bmath.SplineBlend(ki, TI, knotsI, intervalI);

  bj = bmath.SplineBlend(kj, TJ, knotsJ, intervalJ);

  outputGrid[i, j].x += (controlGrid[ki, kj].x * bi * bj);

  outputGrid[i, j].y += (controlGrid[ki, kj].y * bi * bj);

  outputGrid[i, j].z += (controlGrid[ki, kj].z * bi * bj);

  }

  }

  intervalJ += incrementJ;

  }

  intervalI += incrementI;

  }

  intervalI = 0;

  for(i = 0; i < RESOLUTIONI-1; i++)

  {

  outputGrid[i, RESOLUTIONJ-1] = Vector3.zero;

  for(ki = 0; ki <= NI; ki++)

  {

  bi = bmath.SplineBlend(ki, TI, knotsI, intervalI);

  outputGrid[i, RESOLUTIONJ-1].x += (controlGrid[ki, NJ].x * bi);

  outputGrid[i, RESOLUTIONJ-1].y += (controlGrid[ki, NJ].y * bi);

  outputGrid[i, RESOLUTIONJ-1].z += (controlGrid[ki, NJ].z * bi);

  }

  intervalI += incrementI;

  }

  outputGrid[i, RESOLUTIONJ-1] = controlGrid[NI, NJ];

  intervalJ = 0;

  for(j = 0; j < RESOLUTIONJ-1; j++)

  {

  outputGrid[RESOLUTIONI-1, j] = Vector3.zero;

  for(kj = 0; kj <= NJ; kj++)

  {

bj = bmath.SplineBlend(kj, TJ, knotsJ, intervalJ);

outputGrid[RESOLUTIONI-1, j].x += (controlGrid[NI, kj].x * bj);

outputGrid[RESOLUTIONI-1, j].y += (controlGrid[NI, kj].y * bj);

outputGrid[RESOLUTIONI-1, j].z += (controlGrid[NI, kj].z * bj);

intervalJ += incrementJ;
outputGrid[RESOLUTIONI-1, j] = controlGrid[NI, NJ]; }

```

---

<div class="post-metadata">

### Author: ![LeftyRighty](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@LeftyRighty](https://discussions.unity.com/u/LeftyRighty)
#### Post date: [August 23, 2015, 8:22pm UTC](https://discussions.unity.com/t/help-with-game/594701/2 "2015-08-23T20:22:11Z")

</div>

[code][/code] tags, there is a sticky at the top of the forum on them…

---

<div class="post-metadata">

### Author: ![Cat\_cop](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Cat\_cop](https://discussions.unity.com/u/Cat_cop)
#### Post date: [August 23, 2015, 8:33pm UTC](https://discussions.unity.com/t/help-with-game/594701/3 "2015-08-23T20:33:12Z")

</div>

??

---

<div class="post-metadata">

### Author: ![Timelog](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/timelog/32/307301_2.png) [@Timelog](https://discussions.unity.com/u/Timelog)
#### Post date: [August 23, 2015, 8:38pm UTC](https://discussions.unity.com/t/help-with-game/594701/4 "2015-08-23T20:38:02Z")

</div>

> [@Cat\_cop](#):
>
> ??

[http://forum.unity3d.com/threads/using-code-tags-properly.143875/](http://forum.unity3d.com/threads/using-code-tags-properly.143875/)

---

<div class="post-metadata">

### Author: ![Shears](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@Shears](https://discussions.unity.com/u/Shears)
#### Post date: [August 23, 2015, 8:56pm UTC](https://discussions.unity.com/t/help-with-game/594701/5 "2015-08-23T20:56:52Z")

</div>

Parsing error usually mean you have too many or not enough “{” or “}”

---

<div class="post-metadata">

### Author: ![Cat\_cop](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Cat\_cop](https://discussions.unity.com/u/Cat_cop)
#### Post date: [August 23, 2015, 9:03pm UTC](https://discussions.unity.com/t/help-with-game/594701/6 "2015-08-23T21:03:45Z")

</div>

BTW It would help a lot if some1 could send a download link to the _Correct_ File for the BSplineSurface.cs script file.

This is very hard for me.

---

<div class="post-metadata">

### Author: ![zombiegorilla](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/zombiegorilla/32/948729_2.png) [@zombiegorilla](https://discussions.unity.com/u/zombiegorilla)
#### Post date: [August 23, 2015, 10:09pm UTC](https://discussions.unity.com/t/help-with-game/594701/7 "2015-08-23T22:09:06Z")

</div>

The error will tell you what line the problem is on. What exactly is the error message you are getting?

---

<div class="post-metadata">

### Author: ![tedthebug](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/tedthebug/32/391213_2.png) [@tedthebug](https://discussions.unity.com/u/tedthebug)
#### Post date: [August 23, 2015, 10:52pm UTC](https://discussions.unity.com/t/help-with-game/594701/8 "2015-08-23T22:52:57Z")

</div>

Count the number of { & compare it to the # of }, a quick count looks wrong (but it’s early here so I could be wrong myself). Also, is the constructor correct?

---

<div class="post-metadata">

### Author: ![BrendanKZN](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/brendankzn/32/240261_2.png) [@BrendanKZN](https://discussions.unity.com/u/BrendanKZN)
#### Post date: [August 24, 2015, 9:55am UTC](https://discussions.unity.com/t/help-with-game/594701/9 "2015-08-24T09:55:07Z")

</div>

Don’t take this personally. If you want to copy and paste someone’s code they provided and don’t have the time to go through the code yourself and see you missed about 3 }'s towards the end of the script I’m not sure your quite ready to make video games yet. Go through the code yourself after pasting, format it correctly and you will see what your missing a mile away. Good luck.

---

<div class="post-metadata">

### Author: ![Cat\_cop](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Cat\_cop](https://discussions.unity.com/u/Cat_cop)
#### Post date: [August 24, 2015, 10:39am UTC](https://discussions.unity.com/t/help-with-game/594701/10 "2015-08-24T10:39:32Z")

</div>

Nope didn’t do that. I wrote it myself after looking at it online. What happened is it worked the first time, but then the little script editor thingy didn’t save my work the second time. Then that script up above showed up.

I can’t tell if it is because my cat stepped on my F4 Key [Since I have a Lenovo laptop, the F4 key force closes the current window open.] and closed the window, or if the script editor crashed… or something…

Still… could someone **_PLEASE_** write this script as well as BSplineMath script and post a link to a download site for me. I am a beginner… so I kinda might do a bad job on my game. But if someone could post a download, I will post pictures and see what you think of it SO FAR. Very little content, but I will still show pictures.

---

<div class="post-metadata">

### Author: ![tedthebug](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/tedthebug/32/391213_2.png) [@tedthebug](https://discussions.unity.com/u/tedthebug)
#### Post date: [August 24, 2015, 11:00am UTC](https://discussions.unity.com/t/help-with-game/594701/11 "2015-08-24T11:00:52Z")

</div>

If you want someone to write your script for you you need to post in the collaboration thread.
