Strange collision problem with block and terrain

Hey folks.

I have blocks falling from the sky onto some terrain. The blocks are tagged “Block” and the terrain is tagged “Ground”.

The block has the following code attached to it:

http://pastebin.com/91pir1gA

I have another piece of code elsewhere which basically does the same thing but increases the width - and this is working perfectly, i.e makes the progress bar grow. The idea of this code is - when the block touches the ground - the progress bar should shrink.

2 questions:

1/I would expect the collision to be tagged as “Ground” - yet it is always tagged “Block” when the block hits the ground - remembering that this script is attached to the Block itself, this seems odd.

2/The progress bar does not shrink…

Please help!

The pastebin has expired so here it is again : http://pastebin.com/UKxJWieW

I don't really get it, if the script is attached to the block why are you checking if it collides with "Block" -if(col.gameObject.tag == "Block")-?

Thats the whole question...i should be checking against "Ground" not "Block" , but for some "Ground" check never fires and the check with "Block" fires when it hits the ground...additionally the bar does not retract.

1 Answer

1

I have no idea what the problem was - but after a bit of debugging i solved it by retagging both block and terrain :slight_smile: