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 Antonios · Nov 02, 2010 at 03:32 PM · transformplayerobjectmoveclose

Opening a door at proximity

Hi. I would like a door that opens as soon as the player get's close enough (no need to press any button). The player is a Standard Asset prefab for an FPS. To door would open vertically and go up as soon as the player get's close to it. Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Persona · Nov 02, 2010 at 03:36 PM

Set up an empty game object in front of the door, make the collider a trigger, and attach an OnTriggerEnter code on it. Compare the tag of the collider and if it's "Player" tag, have the animation play and the door open.

Comment
Add comment · Show 3 · 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 Antonios · Nov 03, 2010 at 11:21 AM 0
Share

How do I make the animation?

avatar image Matti Jalopeura · Nov 03, 2010 at 02:58 PM 0
Share

Antonios, you could for example make a script that would slowly raise the door a certain amount. Then perhaps do the opposite on OnTriggerExit.

avatar image Antonios · Nov 04, 2010 at 01:52 PM 0
Share

$$anonymous$$y animation makes the door Open and Close directly, how do I split the animations? I made them with unity so they do not appear on the FBXimporter...

avatar image
0

Answer by MohdGasim · Nov 13, 2010 at 12:00 PM

HI....although a newbie to both Unity and scripting...i found this using Raycast, just make sure your door has a collider and Is Trigger is off....

var RayCastlenght = 2; //allows you to change the distance required to trigger the door

function update() { var hit : RaycastHit;

//check if we are colliding if(Physics.Raycast(transform.position, transform.forward, hit, RayCastlenght)) { //...check colliding with door if(hit.collider.gameObject.tag == "BookCase") {

         //move the case
         hit.collider.gameObject.animation.Play("BookCase_anim");
     }
 }

}

what you need to do is compose an animation for the door to open and then change Bookcase_anim with your new animation.....

best of luck

Comment
Add comment · Show 1 · 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 Antonios · Nov 16, 2010 at 01:01 PM 0
Share

Thanks, this helped^^

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

No one has followed this question yet.

Related Questions

Make Object Move to another Object 1 Answer

Lerp a Object along X and Z axis only. 3 Answers

Need help getting my character to move 2 Answers

Object Disappearing when comes close to player. 1 Answer

How do you make an object go left and right? 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