• 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 hherzog · Feb 15, 2013 at 03:17 AM · collisionphysicscollidercubewall

How to destroy the cube which I selected with the arrow key

The cube is the green one. I wanted for instance press the left arrow and destroy only the left cube without destroying the others around it.

alt text

picture.jpg (21.2 kB)
Comment
Add comment · Show 1
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
avatar image robertbu · Feb 15, 2013 at 04:53 AM 1
Share

Physics.Linecast() is one possible solution where you use the Transform.right vector for the check. You will need to use Raycast layers or remove the collider from the green cube to make it work.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by MountDoomTeam · Feb 15, 2013 at 05:53 AM

have a look at script to select object with mouse using mouse button, and then 3 lines to say when you press D, the selectedCollider.GameObject is destroyed.

Comment
Add comment · Share
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
avatar image
0

Answer by hherzog · Feb 18, 2013 at 12:57 AM

I did it another way: I created 4 cubes as children and used "IsTrigger." When I press the arrow matched the corresponding cube changes "IsTrigger" to "true". Works like a charm. : D

alt text


picture.jpg (43.6 kB)
Comment
Add comment · Share
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

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

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Best collision detection method? 2 Answers

Velocity data from OnCollisionEnter is delayed (incorrect) 2 Answers

How can i create a character like dragon hill game, Digging underground, what collider should i use? 0 Answers

Collider2D that not collides 1 Answer

Is it possible to implement a conditional collision response? 2 Answers

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