[Unity3d] using a collision body as a trigger for automatic door opening

Source: Internet
Author: User

The use of triggers in game making is very convenient and very practical. This is a brief introduction to how to use a simple trigger to achieve the automatic door closing effect.
First make sure that you have animated settings on the door.
The specific process is as follows.
Select Window->animation to open the Animation window, select the door where you want to add the animation, and click the Red button to create a new animation.


After selecting a feature that needs to be animated (such as Postion.x), click the Add keyframe button:


Drag the timeline to let go at the end of the animation:


In the scene, drag the door to where you want to stop, creating keyframes for the end of the animation:


Click the Play button on the animation panel to preview the effect of the door.
At this point, the simple animation even finished the production.
The next step is making the trigger.
First, add a Gameobject->creaateother->sphere spherical object and use it as a trigger.


Once created, remove the checked meshrender to make the sphere transparent:


Add a unity-brought script to the sphere to make it function as a trigger:


Select the target object for the trigger:


Set its active event to animate:


However, this time the sphere is a collision body, can not be rushed into the implementation of the trigger function, so you need to check the IS trigger option:


Run again this time and you will find that the door will open automatically as we approach it.

For more information, please visit the "Dog Planing Learning Network" http://unity.gopedu.com

Disclaimer: This document is from the "Dog Planing Learning Network" community, is the Netizen self-published Unity3d study articles, if there is any content violated your relevant interests, please communicate with the official, we will deal with the real-time.

[Unity3d] using a collision body as a trigger for automatic door opening

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.