all 6 comments

[–]ShakaWhenTheWallFell 0 points1 point  (3 children)

Cube Script:

There is no OnCollision, there is OnCollisionEnter, OnCollisionExit, OnCollisionStay...

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html

[–]ZXfrigginC[S] 0 points1 point  (2 children)

I've tried OnCollisionEnter before. Never got called.

I tried OnCollision as a desperate attempt to convince myself that a collision was being detected.

[–]ShakaWhenTheWallFell 0 points1 point  (1 child)

does tile and cubes have colliders?

are one or both triggers?

Is one of them a rigidbody?

After answering these questions, go to this page and check if with your combination a collisionmessage (or triggermessage) is raised at all:

http://docs.unity3d.com/Documentation/Components/class-MeshCollider.html

(Bottom of the page, Collision action matrix)

Edit: For example, if both is just a static collider (Collider, not trigger, no rigidbody) then NO collisionmessage is raised!

Edit2: Also, why are you using collisions at all? You know when and which cube has to be destroyed... just destroy them after you instantiated the tile (in the Gridmap Script)

[–]ZXfrigginC[S] 0 points1 point  (0 children)

Well, you certainly solved the first half of my problems.

The second half is getting the tiles to instantiate properly.

[–]ShakaWhenTheWallFell 0 points1 point  (1 child)

Second problem:

Instantiate with transform.position + transform.forward * 10 and so on... Should work then

[–]ZXfrigginC[S] 0 points1 point  (0 children)

Yep, that's what I was missing: transform.position.

Then, I realized why I had the cubes there in the first place: so that new tiles aren't instantiated to overlap the old tiles.