Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by millerizi · Dec 29, 2016 at 10:09 PM · doorslidedevices

Unable to have door Slide up after pressing Ctrl to move down, Unable to find issue in my code.

I am working on getting a door to slide down in 3D application, I am able to get it to go down, but when I press the button again it doesn't go up, see what I have below:

 public class DoorOpenDevice : MonoBehaviour {
     [SerializeField]  private Vector3 dPos;
 
     private bool _open;
     private void Operate()
     {
         if (_open)
         {
             Vector3 pos = transform.position - dPos;
             transform.position = pos;
         }
         else
         {
             Vector3 pos = transform.position + dPos;
             transform.position = pos;
         }  
         _open = !_open;
     }
 }

I have the dPos set to 0, -3, 0 in the Inspector for the door, and then I have a script that is attached to the user that calls Operator, this defines when I can press "Ctrl" on my keyboard and then it drops door down, but when I press again it doesn't go up. public class DeviceOperator : MonoBehaviour { public float radius = 8.0f;

     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.GetButtonDown("Fire1"))
         {
             Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius);
             foreach(Collider hitCollider in hitColliders)
             {
                 hitCollider.SendMessage("Operate", SendMessageOptions.DontRequireReceiver);
             }
         }    
     }
 }

Any ideas or nudges in right direction will be appreciated.

Thanks.

Comment
Add comment · Show 2
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 PizzaPie · Dec 30, 2016 at 11:59 AM 0
Share

$$anonymous$$aybe the radius is not enough to detect the door while it is down?A simple debug.log with the items of the list should reveal that. Tested the code and it works.

avatar image millerizi PizzaPie · Dec 31, 2016 at 10:27 PM 0
Share

Thank you for the reply, that didn't seem to change anything, I added a Debug.Log and found that it works going down, but it never goes back for the second click and no action is taken, Going to try again maybe I missed something in linking the Scripts in the UI.

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.

Follow this Question

Answers Answers and Comments

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

Related Questions

trying to make my fps controller go through a wall with a doorway the wall has a mesh collider how do i adjust to go through the door 0 Answers

Open/Close Door only if player is near the Door 1 Answer

Unity vr device support 1 Answer

Door open/close sound effect?? 0 Answers

C# - How can i solve this door problem in script? Can someone help me? 1 Answer


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