• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by needforbleed · May 30, 2015 at 04:51 PM · collisiontetris

How to delete GameobjectS on collision??

Hey guys, this question is anwered a thousand times,but i cant handle it. What im doing right now is building an Tetris like 3D Game. The Problem now is,that i cant build a simple row or something like this and when its filled just delete it. My first idea was to look up how many Blocks can the platform on which the blocks are placed take. But this idea was fast thrown away,cause the blocks vary in their sizes. So what im searching for now is how i can detect the number of blocks lying on the platform and second how can i destroy multiple blocks(gameobjects) lying on that platform at the same time because this is not working ,too.Unity just destroys teh last block placed nothing more if the counter for the blocks hits the limit. I gonna post my code here now. You can irgnore bool grabbed as its inherited from another class

Thanks for helping!!

using UnityEngine; using System.Collections;

public class ROwsystem : MonoBehaviour { public static bool grabbed; public int filledrow; public GameObject g; public Collider col; // Use this for initialization void Start () {

     col = GetComponent<Collider> ();
 }
 
 // Update is called once per frame
 void Update () {
 

     if (filledrow ==5) {
         
         
         filledrow = 0;
         Destroy(GameObject.FindWithTag("row1"));
         
     }
     

 }

void OnCollisionEnter(Collision other) { if(other.gameObject.tag=="block") filledrow ++;

     other.gameObject.tag = "row1";

 
     

         
         



 }
 void OnCollisionExit(Collision other)
 {
     filledrow--;
     
     
 }
 void OnCollisionStay(Collision other)
 {
     other.gameObject.tag = "row1";
     
 
 
 }




 void OnGUI()
 {

     GUI.Label (new Rect (150, 0, 100, 20), "" + filledrow ); 
 }



}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

CharacterController:disable character-to-character collision 2 Answers

The timer starts after a collision with an object 1 Answer

Collisions, tags, and enemy types 1 Answer

Particle Collision / Trigger not being reported to On_xx Event 1 Answer

particle system Collision issue 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges