Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 DaniDiaz · Jun 05, 2016 at 04:14 PM · rotationrigidbody2dcollider2dcollision2dtetris

Disable click action when collision

I have a 2D block falling (like tetris) and is rotating when click on this. I would to disabled this action (rotation when click) when the blocks do collision with the ground. I try this but I don´t know why but it isn´t work. The rotation work but it doesn´t stop This is the script to stop the rotation:

var rotar = rotaralclick;

 function OnTriggerEnter(Otro : Collider)
 {
     if (Otro.gameObject.name == "suelo") 
     {
         GetComponent.rotar.enabled=false;
     }
 }


and this is the script of the rotation, in the same prefab

 function Update ()
 {
     if(Input.GetMouseButtonDown(0))
         transform.Rotate(0, 0, -90);
 }
 
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
1
Best Answer

Answer by ownerfate · Jun 06, 2016 at 11:42 PM

for your Bottom script, add the variable: var hasLanded = false;

this is what it should look like in the top Script:

  function OnTriggerEnter(Otro : Collider)
  {
      if (Otro.gameObject.name == "suelo") 
      {
          GetComponent.rotar.enabled=false;
         this.GetComponent( bottom Script name Goes here ).hasLanded = true;
      }
  }


and the bottom Script should look like this:

 var hasLanded = false;
 
  function Update ()
  {
 if(hasLanded == false)
 {
      if(Input.GetMouseButtonDown(0))
          transform.Rotate(0, 0, -90);
  }
 }


if i am reading what you're saying, and both scripts are indeed on the same object, this will work.

hope this helps.

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 DaniDiaz · Jun 10, 2016 at 05:25 PM 0
Share

Thank ownerfate, the botton script work perfectly, but the second script didn´t work well, I change ontriggerenter and I wrote Oncollisionenter2D and it´s fine. Probably it was only a problem of my scene.

avatar image ownerfate DaniDiaz · Jun 11, 2016 at 01:07 AM 0
Share

anytime, and yeah, it might had been, then again, maybe not, that's the wonders of program$$anonymous$$g, ha ha

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2d rigidbody falling from the collider when it is moved 3 Answers

Rigidbody2D with edgecollider adding force on collision 0 Answers

Fixing an inconsistent 2D collision 0 Answers

Polygon Collider 2D weird behaviour when rotating 0 Answers

Check if rocket has stopped moving and landed perfectly (check the speed at it has landed and if a specific collider is colliding) 0 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