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 Aristotless · Sep 10, 2012 at 03:10 AM · triggerobjectfalling

Trigger Falling Object

To be more precise, I am creating a Horror Game. An was thinking of making an object (Scary dead guy) fall down. I was thinking of making it so while the player is moving. An invisible ground trigger is triggered and the object falls. Is that possible? An if so, how? Thanks in return. An I'm kinda still new to Unity. (I can use Scripts fine though) so explain briefly please. 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by adrenak · Sep 10, 2012 at 04:44 AM

Hi, You can follow these steps to do it

1) Have a trigger to detect the player. Identifiy the player using a tag or its game object name

2) Have a script in the trigger. It primarily takes two variables, one is a Transform object which you position in the level where you want the dead man to be put and the other in a GameObject which can be a prefab of the dead guys' body.

3) Use Instantiate to spawn the dead guy at the Transform variables position.

Here's a script :

 var pos : Transform;  
 var deadGuy : GameObject;  //a prefab of the dead guy
 
 function OnTriggerEnter(other : Collider){
 
     if(other.gameObject.tag == "Player")
         Instantaite(deadGuy, pos.position, pos.rotation);
 }
 

Assign this script to the trigger. Then make an empty game object and position it in the level where you want the dead guy to appear.Drag this empty gameObject from heirarchy to the variable `pos` in the inspector window of the trigger.

You also need to have the dead guy ( it can be anything, a horse, soda can etc) as a prefab, or it can be present anywhere in the game world. Drag it to the variable `deadGuy` in the script attached to the trigger. The last thing is, tag the player as "`Player`" from the inspector window.

Tell me if you don't follow. Hope this helps!

Comment
Add comment · Show 8 · 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 Aristotless · Sep 10, 2012 at 09:53 AM 0
Share

Like I said, I'm new. So this is a bit confusing, can you work it step by step for me please?

avatar image Aristotless · Sep 11, 2012 at 10:53 AM 0
Share

I'm getting these errors after pasting the script and saving it: UCE0001: ';' expected. Insert a semicolon at the end. BCE0043: Unexpected token: Collider. and BCE0043: Unexpected token: ;.

avatar image adrenak · Sep 11, 2012 at 06:16 PM 0
Share

$$anonymous$$ade some change there, had punctuation errors

avatar image Aristotless · Sep 11, 2012 at 07:57 PM 0
Share

Now I'm getting: BCE0005: $$anonymous$$ identifier: 'Instantaite'.

avatar image Aristotless · Sep 12, 2012 at 11:02 AM 0
Share

Nvm, I got it. *Instantiate. Testing..

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

TriggerEnter, useGravity, Cubes are not falling down 3 Answers

Emit Particle upon Death 2 Answers

how to set rotation / position of an object on trigger? 2 Answers

Targeting child object components based on a trigger. 0 Answers

multiple Objects Enter OnTriggerEnter 2 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