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
1
Question by Joe 7 · Nov 05, 2010 at 05:12 AM · animationtriggermovewalls

moving my wall up & down

So I am very new to the whole Idea of creating games and such. I have read most of the unity manual, but I am having a hard time understanding, and creating the script to make a wall move up and down using a collider. I have found a few tutorials that use doors as their example from imported models, but I can't find one to teach me the script for a wall. I want the first person controller to walk into the wall and the wall go down so you can pass through then have it go up after a few seconds. I understand collider (i think) I know how to make the animation which I called (WallUp), and another for "WallDown" within unity. My problem is getting the script rite. Every time I hit game to play I get errors. After many alterations, and many tutorials I did nothing but confuse myself. I know the script is simple, and I am a little embarrassed to ask for a script, or a direction to find scripts. Any help would be so helpful. I would post my script but I know it is so messed up that it would be pointless.

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 · Nov 05, 2010 at 05:38 AM 2
Share

It's never pointless to post a script, no matter how messed up. You might learn the concepts behind the solution, rather than just copy-pasting someone else's fix! Also, 'tags' are used to categorise your post, so it will find similar posts, and appear on other related search results.

avatar image PeterDC · Nov 05, 2010 at 05:41 AM 0
Share

@$$anonymous$$arowi: Whoops, posted right after you(basically saying the same things you did).

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Julio Cesar · Nov 11, 2010 at 02:43 PM

Hi,

I think what you need to do is very simple, i tried this one time and it worked:

You have your object wall, and you've animated this wall going up and going down right??

You'll have to use triggers (trigger is an event that ocurs when something happen or collide with it). First you'll need to create a new gameObject empty and place a box collider to it, place this gameObject with the same scale and position of your wall object and add this script to it:

/*=============================================

===============JAVASCRIPT======================

==============================================*/

var wallObject : GameObject; //instantiate you wall object here trough the inspector, just drag and drop your wall object in this variable on the inspector.

function OnTriggerEnter(hit : Collider){

//for this if you'll have to tag your player object as "Player" trough the inspector too.

//this if just check if it is your player that is entering in the trigger

if(hit.Tag == "Player"){

//this will make your wall go up

wallObject.animation.Play("wallUp"); //check the name of your animations

}

}

function OnTriggerExit(){

//here on this function when your player exit the area of the trigger it will play your animation making the wall going down;

wallObject.animation.Play("wallDown"); //check the name of your animation

}

/*===========================================

==============END OF THE SCRIPT==============

=============================================*/

I hope this should help!

Good Luck with your game!!

Comment
Add comment · 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
0

Answer by cmixco · Nov 07, 2010 at 03:47 AM

a simple fix would be using a collider as a trigger and use OnTriggerEnter(call a method to lower door)/OnTriggerExit(call a method to raise door) to make the door open/close or if the door is moving up/down. just make sure the door moves fast enough for the player to get through it.

Comment
Add comment · 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

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

Presure plate that triggers an animation 1 Answer

An odd iTween+RageSpline animation issue with trigger/collider! 1 Answer

Sliding door animation question. 3 Answers

How would I go about making an animation affected by this script? 1 Answer

code to play my animation on button press, but it is looping. What do I add to stop this? 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