Powerup: Missile Problem

Hello all,

I am having problems with my Laser power-up (again). Now I have the missiles firing, two at a time, using the same prefab, but separeted into different game object (clones), so they can hit different targets - I’m not particularly sure how the original Arkanoid handles this - but, I need to check which one has hit the blocks, so, that I can deactivate that missile, then destroy it, and keep the other missile active.

Now I finally figured out - after a LOT of experimentation - thar the missile had to be an IsTrigger object and came up with this code fragment for testing:

/// <summary>
/// if something has collided with the Missile.
/// </summary>
/// <param name="coll">Coll.</param>
void OnCollisionEnter2D(Collision2D coll){
	print ("missile has collided with Something: ");
}

but, the when the missile hits the blocks the print statement never occurs, and I can’t figure out why?

Any assistance would be greatly appreciated and as always a big thankyou in advance!

Regards.

Is the script definitely attached to the object with the 2D collider?

What exactly do you mean by attached?

The prefab of the missile has a Box Collider 2D component:

Is this what you are referring to?

And your script is on that GameObject?

Well, I’m not certain to what you are referring please remember I really am a noob. I haven’t used Unity in a structured way ever before this course and have had a huge break from doing any programming for a long-time.

Now the script is on an empty GameObject (like LevelManager), so, the script can be accessed. The GameObjects, the two missiles are spawned in the script, when the left mouse button is pressed - they are clones of the prefab “new_missile” listed above. Does that make sense?

It looks like I’ll have to abandon this Block Breaker project at this time - and perhaps come back to it some time later New Year because I’ve tried everything I could possibly think of the get the Laser power-up working at it’s just beyond me - and I’m just bogged down and going nowhere. I think through all the reading of the Unity docs I’ve learnt a little bit that may be useful down the track. It’s really disappointing it’s like another failure at the end of a miserable year :unamused:.

Hopefully next year things will be better.

Hey Vaughan…

Look back to when you started this, what you knew then, what you know now, the journey… I would measure your achievement on this from where you were to where you are - not where you are and where you want to be - that achievement is still to be had, and can be.

You have the confidence to expand this game and add much more functionality to it than was covered in the lectures - how cool is that!

In the above conversation, I believe Sam was asking whether the script which you have the print ("missile has collided with Something: "); line in is attached to the missile game object. By attached he refers to it being a component of that game object, e.g. in your screenshot, at the bottom there is the Add Component button (you can also just drag the scripts in this area).

It may be that a little break from it whilst all the chaos of the end of year festivities take place may help - but equally - if you want another set of eyes on this then I am more than happy to offer some support.

I figure we have 12 days until next year, just as a heads up though, I have my son with me this week, so most of my time during the day will be spent with him, but I will be free on the evenings (after about 9pm UK time).

Let me know - if it helps make the end of your year a bit better, I’d be happy to help if I can.

1 Like

Privacy & Terms