Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Mr.Poxycat · Jan 29, 2014 at 01:20 PM · destroycubelogicfloating

Can i destroy this cube? Logic??

Hi,

How can i check if there is any cubes "floating". Easier to explain the problem if i show you some examples.

alt text

Example 1: I wanna remove cube 1. I shouldn't be able to, because cube 2 will be floating, i could check this by looping through all cubes and see if there is anybody that isn't colliding with a cube, and if there is its a no go. But that method doesn't work because of example 2.

Example 2: I wanna remove cube 6. Now the colliding method doesn't work here because even though 7,8,9 and 10 are floating they are still colliding with a cube.

Hmm, i find this hard to explain. So basically, you can click on any cube to destroy it, but you shouldn't be able to destroy it if there is any cubes "floating" after the cube gets destroyed.

Also, all these cubes are build by the player so i can't predict they're positions. And they can be build in ANY form.

How can i check this? I have no idea my brain doesn't work right now! I would appreciate any help i can get!

unavngiven.png (1.7 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by midomido · Jan 29, 2014 at 01:25 PM

Maybe you can raycast to see if the cube is standing on another cube ?

bool IsGrounded(){
return Physics.Raycast(transform.position,-Vector3.up, CubeLength); }

Comment
Add comment · Show 2 · 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 Mr.Poxycat · Jan 29, 2014 at 01:44 PM 0
Share

I tried that but it won't work because the cube can be placed anywhere on the screen as long as it is touching another cube so it can be right at the corner of another cube, it can be below,the sides and in the middle of 2 cubes.

EDIT: Even if i succeeded at checking if it is touching another cube and that cube is touching another cube and so on... How would i know if they are not connected to the main piece(cube 0).

avatar image midomido · Jan 29, 2014 at 01:58 PM 0
Share

Try doing 4 ray casts up down left right from the cube position when you try to delete it

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.

Follow this Question

Answers Answers and Comments

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can i destroy cubes that is randomly generated when i have passed them? 1 Answer

Destroying One Object Destroys Another? 1 Answer

[Solved]How to destroy a turret in Tower Defense game 2 Answers

Something wrong with destroying script 0 Answers

Explosion before destroying 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges