Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Opening Doors When They Are Clicked Unity Reflect

Discussion in 'Architecture, Engineering & Construction' started by grimPatreon, Jul 28, 2020.

  1. grimPatreon

    grimPatreon

    Joined:
    May 19, 2020
    Posts:
    1
    While editing the Unity Reflect prefab I've been running into a few problems. The goal is to have a door be touched by the user (Either by mouse on pc or touch on mobile) and animate open. Do you guys have any suggestions because I have been having a lot of trouble coming up with the logic. I am an intermediate Unity and C# developer.

    The logic that I've been thinking of goes something like this (keep in mind I don't know exactly how to code this it's just the thought process I've gone through. I was planning on just coding a for loop that goes through and stores all pieces of the Revit model that have door metadata from Revit. I would then have an if loop that checks if that door is in the loop. This check would happen every time the user clicked the screen. If it is in the loop I would rotate it by 90 degrees over a set period of time to make the animation smoother.

    Versions:
    Unity Version 2019.4.1f1
    Unity Reflect Version: 1.2.0

    Any thoughts or responses are greatly appreciated.

    Thank You!
     
  2. quintus_smit

    quintus_smit

    Joined:
    May 15, 2019
    Posts:
    3
    I wouldn't run the loop ever time there is a click, that is unnecessary overhead, especially on mobile. I would rather have a script that runs through once and then add an "Open door" script to each object that has the door type in the metadata. That way it only needs to happen once.

    There are three problems I see with this, however:
    1) There is no event that tells Unity the model is done loading. If this is done with an imported model it is not a problem but if you are doing it with a streamed model the script should only run once everything is loaded. *see comment below
    2) How do you distinguish between swing and slide doors (maybe have a specific project property set up in the metadata?)
    2) How do you know where the pivot point is on each door (right hand or left hand)

    *Fred Moreau found a workaround where he counts the number of imported elements via a script and then compares it with the expected number in the package
     
unityunity