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 kilian277 · Jun 28, 2012 at 09:39 AM · vehicleexitenterhelicopter

vehicle enter/exit, player position problem after exiting

Hi,

i've managed to create a simple enter/exit system with this link text as reference

now the problem is whenever i exit the vehicle (in this case a helicopter) the player always comes on the place where the exit point previously was.

Here's the script:

var enter_left : GameObject; var enter_right : GameObject; var player_object : GameObject; var player_cam : GameObject; var helicopter : GameObject; var sitting_object : GameObject; var cambackf : Camera;

private var audio1 : Component; private var in_heli : boolean = false; private var ok : boolean = false; private var play : boolean = false;

function Start () {

}

function Update () {

 if(Input.GetKeyUp(KeyCode.F)&& ok==true){
     in_heli = true;
     ok=false;
     // make player invisible and still standing
     player_object.gameObject.SetActiveRecursively(false);
     player_object.active = false;
  
     //make player cam inactive
     player_cam.gameObject.SetActiveRecursively(false);
     player_cam.active = false;
     //make main helicam active
     cambackf.active = true;
     //make helicopter controls active
     GameObject.Find("heli").GetComponent("Helicopter_Controller").enabled = true;
     GameObject.Find("heli").GetComponent("HELI_cammodes").enabled = true;
     //position of player
     //parent player to exitpoint
     player_object.parent = enter_right.transform;
     player_object.transform.position = Vector3(-1.5,0,0);
     
     //play the motor sound
     helicopter.audio.Play();
     
 }else{
     if(Input.GetKeyUp(KeyCode.F) && in_heli==true){
     in_heli = false;
     ok=false;
     //make helicopter controls inactive
     GameObject.Find("heli").GetComponent("Helicopter_Controller").enabled = false;
     GameObject.Find("heli").GetComponent("HELI_cammodes").enabled = false;
     //make main helicam inactive
     cambackf.active = false;
     // make player visible
     player_object.gameObject.SetActiveRecursively(true);
     player_object.active = true;
     //make player cam back active
     player_cam.gameObject.SetActiveRecursively(true);
     player_cam.active = true;
     //parent player to null
     player_object.transform.parent = null;
     
     //stop the motor sound
     helicopter.audio.Stop();
 }
 }

} function OnTriggerEnter(player_object : Collider){ ok = true; } function OnTriggerExit(player_object : Collider){ ok = false; }

Can somebody tll me where the problem exactly is ?

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

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Enter/Exit vehicle 0 Answers

Car Enter/Exit Script Multiple Cars Problem 4 Answers

Problem Enter and Exit with Vehicle 2 Answers

How do you make character enter and exit vehicles. 1 Answer

could someone help with entering/exiting a vehicle? 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