Hello,
I am working through the old FPS Tutorial, and everything has been going smoothly up until this point. I have managed to create a launcher that launches the “Missile” GameObject, which is a grey sphere. My problem arose when the time came to assign a GameObject to the “Explosion” variable in the “Projectile” script (Projectile.js was a component of Missile.prefab).
Basically, this is what happens: I fire with Left-click (Fire1) and it simply spawns an explosion at my character (the capsule). It SHOULD be launching the sphere and then exploding upon collision with other objects.
I can provide code if it helps, but I am stuck at this point and do not know what to do.
Thank you!
In general, yes, post code when asking code questions. Is it possible that your missile is colliding with the player or the launcher? Or that your explosion effect is active already and thus explodes as soon as it is spawned? More information will definitely help.
– iwaldropNice formatting! :)
– iwaldropThe commenting section messed up my layout. Anyways, do you know how I can resolve this issue? You mentioned something about it becoming active and exploding immediately, so is there a way for it to become active upon collision?
– SoozleIf you look at the code, when OnCollisionEnter is called on the Projectile the explosion gets instantiated. As I suspected, your missile is likely colliding with something as you're firing it.
– iwaldropThat's what I thought as well, but when I launch the Missile object without the Explosion GameObject in the Explosion variable (in the Projectile script [in inspector]), it launches fine.
– Soozle