- Home /
BCE0005: Unknown identifier: 'Fire'. / Secondary shot?
I'm not sure why I am getting this error...
Im trying to shoot using a particle system, but for some reason im getting this error
BCE0005: Unknown identifier: 'Fire'.
var particleSystem : ParticleSystem;
function Update ()
{
if(Input.GetButtonDown("Fire1")){
Fire();
}
}
I also am trying to figure out how to add a second fire function to my script once i get past this dumb error, This is what I was thinking (below) but I cant even test it cuz of the error.
var particleSystem1 : ParticleSystem;
var particleSystem2 : ParticleSystem;
function Update ()
{
if(Input.GetButtonDown("Fire1")){
Fire(particleSystem1);
}
if(Input.GetButtonDown("Fire2")){
Fire(particleSystem2);
}
}
Is that in the right direction?
Oops :P
Well the thing is, i'm using a particle system so does it need rigid body? I just want the laser to bounce off of a wall. Will I need rigid body on the laser to do damage to the player or something?
Answer by Negagames · May 12, 2013 at 10:22 PM
You never made a function that pertains to "Fire".
function Fire(particleSystem prtcl){
Instantiate(prtcl, transform.position, Quaternion.identity);
}
If I understand what you're trying to accomplish, there is much more that you need here such as a rigidbody or a collider.
I'm trying to shoot a Laser (particleSystem) and have it bounce off of walls but hurt the player if it contacts the player.
That last function you gave me does not work, how would I write a script to shoot particle1 with left mouse click and particle2 with right mouse click, as well as hurt "Player.tag" but bounce off of "Wall.tag"
Put the script here, and are you sure you used the code I wrote correctly?
var particleSystem1 : ParticleSystem;
function Update ()
{
if(Input.GetButtonDown("Fire1")){
function Fire(particleSystem1 prtcl){
Instantiate(prtcl, transform.position, Quaternion.identity);
}
I got 4 errors (7,10): BCE0044: expecting (, found 'Fire'. (7,31): BCE0044: expecting ), found 'prtcl'. (7,36): BCE0043: Unexpected token: ). (8,65): BCE0044: expecting :, found ';'.
Im still stuck on this one.... I dont know how to write a Particle Shooting script...
@RickHurd , There is a saying : "One must learn to crawl before they can walk". I feel you don't understand the basic concepts of program$$anonymous$$g. You should really be spending your time learning to program with lots of $$anonymous$$i projects before you attempt your 'big' project idea. You should be spending your time doing one of the gabazillion tutorials out there. Try this one : http://www.unityjumpstart.com/ProofOfConcept_1/
Do i have to do function Fire(){ ?
Yes, you'll need to write some code for that.
Oops :P Well the thing is, i'm using a particle system so does it need rigid body?
This chain of comments makes no sense.
Then your above code example is just a mess. You cannot put a function inside a function.
function Start()
{
// I am a Function
}
function Update()
{
// I am also a Function
// Now I'm going to call another function called Fire
Fire();
}
function Fire()
{
// I am also a Function
// I am being called by the command Fire();
}
Again, I strongly suggest you start small, then work up. Here is a playlist I strongly recommend to all new users : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp
@Negagames , the code in your answer is not correct. It seems to be a hybrid of C# and uJS. Also you missed a capitol in your typecasting of ParticleSystem.
function Fire( prtcl : ParticleSystem )
{
Instantiate( prtcl, transform.position, Quaternion.identity );
}
Your answer
Follow this Question
Related Questions
My gun won't fire. ( Javascript ) 1 Answer
Hold Button Shooting 3 Answers
Firing System with two Shoot Points 1 Answer
Fire outline shader 1 Answer
how do i stop automatic firing? 3 Answers