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 Aurelien_Felin · Jul 22, 2019 at 04:54 PM · triggerhorror

How to make a wall that disappears like Layers of fear ?

Hello, I would like to know how to make a trigger system that activates when the player looks at another place and then makes a wall disappear behind him. Thank you! Thank you!

Like at 00:31. https://www.youtube.com/watch?v=LLH_aKd09YE

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 Vega4Life · Jul 22, 2019 at 06:31 PM

For the example in the youtube video, you need 3 prefabs that are almost identical. A prefab wall, a prefab wall with a door, a prefab wall with a door that is bricked up. This makes them easily replaced/swapped out for other walls.


When the user goes into the room, there is a trigger. When the user exits the trigger (onTriggerExit), and is inside the room, then the wall can be swapped for the prefab of the door that is bricked up. Honestly, this is probably the most work, as you need to make sure they are indeed in the room - you don't want to change prefabs if a user walks into the trigger but walks out the way they came (because that is still a trigger exit). So, you would need to check the room with (maybe) a raycast to the floor - and check the floor space.


The second wall change happens when new wall that was just swapped (door bricked up) comes in LOS to the user. There are a lot of examples out there for that - which is basically checking to see if the user is looking at a specific point. If the new wall is in LOS, the back wall is swapped for a new prefab of a wall with a door.


 public class LookAt : MonoBehaviour
 {
     [SerializeField] GameObject target;
     [SerializeField] float lookDelta = 0.8f;  // 1.0f is directly looking at gameObject
 
     // Update is called once per frame
     void Update()
     {
         Vector3 direction = (target.transform.position - transform.position).normalized;
         float dotProduct = Vector3.Dot(direction, transform.forward);
 
         if (dotProduct >= lookDelta)
         {
             // Change wall
         }
     }
 }


Example above is using a dot product to determine if an object is looking at another. A product of 1 is looking directly at it, -1 is looking completely away.


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 Aurelien_Felin · Jul 22, 2019 at 07:03 PM 0
Share

So how do you know if the player is looking at a specific point in the room? Thank you for your answer

avatar image Vega4Life Aurelien_Felin · Jul 22, 2019 at 07:14 PM 0
Share

Added an example to the answer above.

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

199 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 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 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

How to turn off isTrigger when on Entering and turn on isTrigger on Exiting. 1 Answer

Trigger finds objects without being activated 0 Answers

Trying to get bool statement to work in OnTriggerStay2D 1 Answer

Moving triggers possible? 0 Answers

How to detect the vertices of water4 using a trigger? 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