- Home /
Question by
stevesterrr · Jun 29, 2012 at 03:38 PM ·
erroruce0001
Assets/turret/TurretControll.js(20,2): UCE0001: ';' expected. Insert a semicolon at the end.BIG PROBLEM,now what do I do??
var LookAtTarget:Transform;
var damp = 6.0;
var bullitPrefab:Transform;
function Update () {
shoot();
if (LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation =Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);
}
function (shoot)
{
var bullit = Instantiate(bullitPrefab, gameObject.Find("spawnpoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
}
Comment
Best Answer
Answer by aldonaletto · Jun 29, 2012 at 03:49 PM
The shoot function declaration is wrong, and in the wrong place:
function (shoot)
{
var bullit = Instantiate(bullitPrefab, gameObject.Find("spawnpoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
You should declare the function like below, and
outside any other function:
function shoot()
{
var bullit = Instantiate(bullitPrefab, gameObject.Find("spawnpoint").transform.position, Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 2000);
}
Answer by Loius · Jun 29, 2012 at 03:51 PM
You need to work through some more tutorials, your syntax is all over the place and your indentation will be a huge hassle later when you're trying to fix things.
Move Shoot (as it is a function, it should, but does not have to, be capitalized) outside of Update. Functions inside functions aren't a thing.
function Update() {
/* code */
}
function Shoot() {
/* code */
}
Your answer
Follow this Question
Related Questions
Collision Detector script 1 Answer
Limit rotation for a statue puzzle 1 Answer
array of integer array show compiler error 1 Answer
Semicolon? WHAT? HELP ME! 1 Answer
Desintergrate Enemies on Dying 4 Answers