Ask coding questions

← Back to all posts
Unity help
Bunnytoes

My code is making the bullet not work if there is no target. also if the original enemy dies the next waves don't spawn here are the screenshots

Voters
Bunnytoes
Comments
hotnewtop
Coder100

the error probably came from target make sure you aren't destroying that anywhere else

Bunnytoes

@Coder100 I beleive that the error is comingfrom it destroying the bullet, as when I run it no bullets are shot, but if I remove that code it says that it's missing null referance. Also the other enemies are clones so if the first enemy is destroyed they stop spawning

Coder100

still check
and also make sure you have set all references @Bunnytoes

Bunnytoes

@Coder100 idk what you mean but here is the wavespawner script

Coder100

So in the ide, did you set all the values? @Bunnytoes

Bunnytoes

@Coder100 I am using visual studios. Here are the screenshots(note the target is empty because it gets a target if in range)

Coder100

Well yeah ur using visual studio, what I meant was the unity editor which is an ide @Bunnytoes

Bunnytoes

@Coder100 I don't know what you mean but I have the scripts in unity. Also the code works for brackeys

Bunnytoes

@Coder100 I fixed one error but removing the destroy(gameobject) but I still need waves to spawn when the original enemy dies

Coder100

in your gamemaster, you could make a script to spawn them @Bunnytoes

Bunnytoes

@Coder100 could you please leave the code in a comment for me, it would help me so much! P.S. I just added spawning turrets so it is very needed

Coder100

sure

@Bunnytoes

Bunnytoes

@Coder100 1.can you put all the code(thank you u but that will be more helpful)2. I fixed the bullets issue

Coder100

sure
something like

@Bunnytoes
replace <ur position> and just call createEnemy whenever

Bunnytoes

@Coder100 do you mean

? also should I add a new script to gamemaster?also I just need a way to instaniate the object destroyed or not destroyed

Coder100

if you gave the line numbers in your screenshot that would have helped a lot more

Bunnytoes

@Coder100 ok give me a sec here they are