New to scripting, what's going wrong with this code?

Hi,

I’m trying to do an exercise in a book called Unity 4.x Game AI Programming, and I tried copying some code from the book. When I tried to add the following code to a game object (a tank), I got a pop up that said, ‘Can’t add script behavior PlayerTankController, you need to fix all compile errors in all scripts first’. When I look at the MonoDevelop window, it says I have 0 errors.
Maybe if anyone can give me some constructive advice, that would be great.

using UnityEngine;
using System.Collections;

public class PlayerTankController : MonoBehaviour {

public GameObject Bullet;

private Transform Turret;
private Transform bulletSpawnPoint;
private float curSpeed, targetSpeed, rotSpeed;
private float turretRotSpeed = 10.0f;
private float maxForwardSpeed = 300.0f;
private float maxBackwardSpeed = -300.0f;

//Bullet shooting rate
protected float elapsedTime;

void Start () {

//Tank Settings
rotSpeed = 150.0f;

//Get the turret of the tank
Turret = gameObject.transform.GetChild (0).tranform;
bulletSpawnPoint = Turret.GetChild (0).tranform;
}

// Update is called once per frame
void UpdateWeapon()
{
if (Input.GetMouseButtonDown(0))
{
elapsedTime += Time.deltaTime;
if (elapsedTime >= shootRate)
{
//Reset the time
elapsedTime = 0.0f;

//Instatiate the bullet
Instantiate(Bullet, bulletSpawnPoint.position,
bulletSpawnPoint.rotation);
}
}
}

void UpdateControl()
{
//AIMING THE MOUSE
//Generate a plane that intersects the transform’s
//position with an upwards normal.
Plane playerPlane = new Plane(Vector3.up,
transform.position + new Vector3(0, 0, 0));

// Generate a ray from the cursor position
Ray RayCast =
Camera.main.ScreenPointToRay(Input.mousePosition);

//Determine the point where the cursor ray intersects
//the plane.
float HitDist = 0;

//If the ray is parallel to the plane, Raycast will
//return false.
if (playerPlane.Raycast(RayCast, out HitDist))
{
//Get the point along the ray that hits the
//calculated distance.
Vector3 RayHitPoint = RayCast.GetPoint(HitDist);

Quaternion targetRotation =
Quaternion.LookRotation(RayHitPoint-
transform.position);

Turret.transform.rotation =
Quaternion.Slerp(Turret.transform.rotation,
targetRotation, Time.deltaTime *
turretRotSpeed);
}
}
}

In unity click Window->Console

The error will be listed there.

What does it say?

Double clicking the error should take you to the line throwing the error in mono

Trust Unity’s Console way above MooDevelop’s error console.

…Basically, I mean to reiterate the above. Do that, check what the issue is, and if you still have issues, post the error(s).

Also, please use [ Code ] tags to make your code easy to read, comment on, etc so we can easily help you.