help me, i have an error in this line of code and i cannot understand it
var bulletScript : clone.gameObject.AddComponent(“BulletScript”);
the error was
‘;’ expected.Insert a semicolon at the end
help me, i have an error in this line of code and i cannot understand it
var bulletScript : clone.gameObject.AddComponent(“BulletScript”);
the error was
‘;’ expected.Insert a semicolon at the end
Remove the ‘:’ from
var bulletScript : clone.gameObject.AddComponent("BulletScript");
And do a:
var bulletScript = clone.gameObject.AddComponent("BulletScript");
That is, assuming you’re trying to add the component and get a reference to it at the same time. See AddComponent.
Btw, there’s no need to do this.gameObject
. gameObject
already refers to the game object that your script is attached to. So just:
bulletScript.playerShooting = gameObject;
Did you mean:
var bulletScript = clone.gameObject.AddComponent("BulletScript");
( “=” not “:” )?