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 sketchers1 · Aug 08, 2012 at 11:28 PM · triggerontriggerenterparentchildship

Parenting On Trigger not Working?

Hey Everybody! So I have a Ship that has a Box Collider inside it. When My player collides with the Collider, it activates an AI Script. What I was trying to do was that at the same time, have the Player Made a Child of the Ship So that it goes wherever the AI goes, until nessecary. So therefore the Player needs to be Inactive for a variable amount of time. I was using this script but instead of getting parented, the player just goes flying off the edge! Is there a different script that I should use?

UPDATE! I FINALLY FIGURED IT OUT:

var scriptname1 : GameObject;

function OnTriggerEnter(other: Collider)

{

 if(other.tag == "Player")

 {

 scriptname1.active = false;

    other.transform.parent = transform.parent; 

 }

}

function Update () {

if (Input.GetKeyDown ("e")){

Destroy(gameObject);

scriptname1.active = true;

}

}

Thanks for all your help!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by sketchers1 · Aug 09, 2012 at 03:24 AM

Here is the mostly Correct Script, the one thing I cannot figure out is getting out of the ship.

var scriptname1 : GameObject;

function OnTriggerEnter(other: Collider)

{

 if(other.tag == "Player")

 {

 scriptname1.active = false;

    other.transform.parent = transform.parent; 

 }

}

function Update () {

if (Input.GetKeyDown ("e")){

Destroy(gameObject);

scriptname1.active = true;

}

}

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 cassius · Aug 09, 2012 at 12:30 AM

Not sure but wouldn't "col.transform.parent = transform.parent;" just be "col.transform.parent = transform;"?

Comment
Add comment · Show 1 · 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 Ingen · Aug 09, 2012 at 12:49 AM

hallo, I use this, found somewhere here, on a trigger inside the lift

 var platform : Transform;
 var player : Transform;
 
 function OnTriggerEnter () {
    player.parent = platform;
 }

and this on a trigger just when exit the lift

 var platform : Transform;
 var player : Transform;
 
 
 function OnTriggerEnter () {
   player.transform.parent = null;
 
 }

using OnTrigerExit on the trigger is in the lift don't know why, but don't work

Comment
Add comment · Show 1 · 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 sketchers1 · Aug 09, 2012 at 12:51 AM 0
Share

I saw that source earlier and tried modifying it to fit my needs, but that would not work either.. Thanks Though!

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

OnTriggerEnter not being called with multiple colliders 1 Answer

Make a simple tree 1 Answer

Do Child Objects Trigger Parent Objects? 1 Answer

Parent Script accessing Child components 1 Answer

OnTriggerEnter - check if collider is child 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