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 gustavohw · Feb 08, 2013 at 04:07 AM · pickupitemflashlight

Trigger event from ground and activate the Object-child in the Camera

EDIT2: I can't seen to get it working, can anybody create a simple script for me? As I told before, I have zero knowledge in scripting... I'm trying to learn.

EDIT: This is what I want to do... alt text

Hello, I'm making a atmospheric terror game, and I need help because I have little knowldge in scripting. I need to pick-up a flashlight from the ground, and I already got this working:

 function OnTriggerEnter (myTrigger : Collider) {
     if(myTrigger.gameObject.name == "FPSPlayer"){
         Debug.Log("Flashlight Found");
     }
 }

It shows up right in the console, next thing I need is to add the flashlight to the hierarchy on the parent FPSPlayer (I use Ultimate FPS Camera). And make the flashlight on the ground disappear (This should be rather easy to do). Can anybody point me something?

Thanks everybody.

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 ThePunisher · Feb 08, 2013 at 05:30 AM

Sounds simple enough. I'm assuming the script I'm looking at is on your flashlight, is it? If so, you could try parenting the flashlight to the player.

Try replacing your debug statement with this:

 transform.parent = myTrigger.gameObject.transform;

This should parent the flashlight to your player so that it moves with your player. Now you can just set the transform.localPosition and transform.localRotation to whatever it is you need to get it to look right.

Edit: Oooooh. That's clever. Well, all you have to do then is call Destroy() on the Lantern on the ground, and then enable the one under your camera by using the enabled property.

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

http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html

Comment
Add comment · Show 2 · 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 iwaldrop · Feb 08, 2013 at 05:39 AM 1
Share

This is the way to go. But I might recommend placing a reference transform on your player at the position and rotation that you want your flashlight to be positioned at. This way you place the flashlight where you want in the editor then move the flashlight to the exact position you want it at without a lot of fuss in the code.

avatar image ThePunisher · Feb 08, 2013 at 08:33 AM 0
Share

Good idea.

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

11 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

Related Questions

Help with pickup script 0 Answers

help with Flashlight Pickup 1 Answer

Battery Pickup Regeneration 2 Answers

Rechargeble flashlight with battery pick up 1 Answer

item pickup not working after an item is used. 0 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