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 MercenaryGamer18 · Dec 14, 2013 at 09:15 PM · beginnerappeardissapearderp

how to make an enemy appear then disappear. (if possible with audio)

Hi, this is my second question, I am currently creating my first horror game, but now I need help. I don't know how to make an enemy appear then disappear, in other words, I don't know the script. Please tell me how and if you do give a script please tell me the type. Oh and also, if possible, can an audio be inserted with the character everytime it Appears? Thank you. I will be sure to add you to the credits.

Comment
Add comment · Show 3
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 AlucardJay · Dec 14, 2013 at 09:23 PM 2
Share

http://docs.unity3d.com/Documentation/ScriptReference/Renderer-enabled.html

avatar image Commander Quackers · Dec 14, 2013 at 09:27 PM 0
Share

Appear when you enter a trigger, randomly, or...?

This one deals with triggers and jumpscares:

http://www.youtube.com/watch?v=okr1BmcpePE

avatar image MercenaryGamer18 · Dec 15, 2013 at 07:21 AM -1
Share

Any, just tell me what to do then the script, oh, leave your name too so that you can be in the credits

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Commander Quackers · Dec 15, 2013 at 07:34 AM

Here, just made this, tested and it works: [It's javascript]

 function OnTriggerEnter (other : Collider){
     if (other.gameObject.tag == "Player") {
     renderer.enabled = true;
     yield WaitForSeconds(2);
     renderer.enabled = false;
     }
 }

To use it, attach this to your enemy, and make sure you have a collider (a box collider works best) and check "Is Trigger." When your player enters the box collider, the enemy will appear for 2 seconds and then disappear. You can change the time in WaitForSeconds(); to whatever you like.

You don't need to add me to the credits

Comment
Add comment · Show 6 · 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 Commander Quackers · Dec 15, 2013 at 07:38 AM 0
Share

Oh and for the audio just put "var sound : AudioSource; at the top of the script, and right before the line

 renderer.enabled = true;

put in this line

 sound.Play();

and you should be good to go, just add an audiosource to the enemy object with the sound you want

avatar image MercenaryGamer18 · Dec 15, 2013 at 08:12 AM 0
Share

I have writtn down the script, its ok. But now, I attached it to the zombie $$anonymous$$odel and a message says "There is no renderer attached to the zombie game object, but a script is trying to access it." Please help

avatar image Kiloblargh · Dec 15, 2013 at 08:56 AM 0
Share

var zr : Renderer;

drag the appropriate renderer to the slot in the inspector.

then, ins$$anonymous$$d of renderer.enabled, you can say zr.enabled.

avatar image MercenaryGamer18 · Dec 15, 2013 at 09:00 AM 0
Share

But then where do I find the renderer (sorry I am completely new)

avatar image Kiloblargh · Dec 15, 2013 at 09:26 AM 0
Share

Somewhere in the zombie's hierarchy is an object that has a mesh renderer and a mesh filter component. It's not the root (main game object) or renderer.enabled would not throw an error. The object with the mesh renderer on it is what you need to drag to the zr slot in the inspector.

Show more comments

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

18 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

Related Questions

touch appear let go dissapear? 2 Answers

Materialize an object, then destroy it. 1 Answer

Making an object blinking for some time, then dissapearing 2 Answers

Object Apear WaitForSeconds Disappear 1 Answer

Downsize A 3DS Model? 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