I’m totally new to Unity and coding and am trying to convert some code for Unity into an iPhone game I’m working on, but have one last error that I can’t seem to resolve. It’s telling me I have error BCE0043: Unexpected token: … as far as I can tell on the line and character count it doesn’t like my AddComponent code. My original Unity code was
function InstantiateBullet()
{
if(Time.time > nextFire)
{
nextFire = Time.time + 1.4;
attackEvent.time = tempAttackTime;
animation["attack"].weight = .5;
clone = Instantiate(fireBall, hand.position, hand.rotation);
Physics.IgnoreCollision(clone.collider, collider);
clone.rigidbody.velocity = transform.TransformDirection(Vector3.forward * 20);
var bulletScript = clone.gameObject.AddComponent("BulletScript");
bulletScript.playerShooting = this.gameObject;
}
}
which I then tried to change to
function InstantiateBullet()
{
if(Time.time > nextFire)
{
nextFire = Time.time + 1.4;
attackEvent.time = tempAttackTime;
animation["attack"].weight = .5;
clone = Instantiate(fireBall, hand.position, hand.rotation);
Physics.IgnoreCollision(clone.collider, collider);
clone.rigidbody.velocity = transform.TransformDirection(Vector3.forward * 20);
var bulletScript = clone.gameObject.(AddComponent("BulletScript") as BulletScript);
bulletScript.playerShooting = this.gameObject;
}
}
Any help would be greatly appreciated. Thanks.