Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Locking Y transition

Discussion in 'Scripting' started by Jasper-Hesseling, Oct 14, 2009.

  1. Jasper-Hesseling

    Jasper-Hesseling

    Joined:
    Jul 27, 2009
    Posts:
    34
    Is there a way to lock the Y transition of the FPS controller when using this script?

    Code (csharp):
    1. function OnTriggerEnter () {
    2.    var GO = GameObject.Find("Platform");//whatever the name of your moving platform is
    3.    var GO1 = GameObject.Find("First Person Controller");
    4.  
    5.    GO1.transform.parent = GO.transform;    
    6. }
    7.  
    8. function OnTriggerExit () {
    9.    var GO = GameObject.Find("Platform");
    10.    var GO1 = GameObject.Find("First Person Controller");
    11.  
    12.       GO1.transform.parent = null;
    13. }
    Thanks
     
  2. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    If I understand what you're asking, just use:

    Code (csharp):
    1. transform.position.y = 0; //change 0 to whatever value you desire
     
  3. Jasper-Hesseling

    Jasper-Hesseling

    Joined:
    Jul 27, 2009
    Posts:
    34
    Well actually I want to turn of the gravity for the fps controller. So that it won't fall when you are in the elevator when going down.
     
  4. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    Turn it off in the inspector.

    Choose the object the script is attached to, and under Rigid Body uncheck "Use Gravity"