Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Help a non programmer

Discussion in 'Scripting' started by Dakta, Sep 6, 2008.

  1. Dakta

    Dakta

    Joined:
    Apr 8, 2008
    Posts:
    492
    I am not a programmer, but I have this script I got, and I want to test it really soon. Unfortunately, unity keeps bugging me about "Unknown Identifiers", and I (being not a programmer) am in need of resolution of this ungainly problem.

    P.S. If you like the script, feel free to use it.

    Code (csharp):
    1. function FixedUpdate () {
    2.    gravityUp = attractor.position - transform.position; // away from center
    3.    gravityUp.z = 0; // spin gravity
    4.    gravityUp.Normalize();
    5.    
    6.    heading += 90 * Input.GetAxis("Horizontal") * Time.deltaTime;
    7.    heading = heading > 360 ? heading - 360 : heading;
    8.    heading = heading < 0 ? heading + 360 : heading;
    9.    
    10.    transform.rotation = Quaternion.FromToRotation(Vector3.up, gravityUp) * Quaternion.AngleAxis(heading, Vector3.up);
    11.    
    12.    angleDelta = Vector3.Angle(gravityUp, transform.up);
    13.    
    14.    localForward = transform.forward;
    15.    
    16.    rigidbody.AddForce( gravityUp * fauxGravity * rigidbody.mass );
    17.    
    18.    if (Input.GetAxis("Vertical") > 0.2){
    19.       rigidbody.AddForce(localForward * rigidbody.mass * 10);
    20.       // Unsatisfactory voodoo to let me move on bumpy terrain
    21.       rigidbody.AddForce(gravityUp * rigidbody.mass * 5);
    22.    }
    23.    
    24.    if (grounded  Input.GetButton ("Jump")){
    25.       rigidbody.AddForce(gravityUp * rigidbody.mass * jumpForce);
    26.    }
    27.    
    28. }
     
  2. boomaster_legacy

    boomaster_legacy

    Joined:
    Feb 24, 2008
    Posts:
    262
    im not a programmer but i constantly have the same problem. is the 'identifier' spelled correctly? is there a 'var (etc.)' thing at the beginning telling what the identifier means? if not, try to fix that. that's all i can say tho. oh, and what does the script do? (or what is it meant to do?)
     
  3. marraboy

    marraboy

    Joined:
    Mar 25, 2008
    Posts:
    113
  4. Dakta

    Dakta

    Joined:
    Apr 8, 2008
    Posts:
    492
    The script is rotational gravity around one axis (think tin can on it's side, spinning on the horizontal axis, with you on the inside). Based on what's his name's planetoid gravity script. I guess I'll just have to add the variables myself.
     
  5. marraboy

    marraboy

    Joined:
    Mar 25, 2008
    Posts:
    113
    ok

    I'm a bit confused... Were you wanting somebody to type them in for you? You need a secratary! ;)

    JT
     
  6. Dakta

    Dakta

    Joined:
    Apr 8, 2008
    Posts:
    492
    Nah. I just need my remote programmer to be more timely . :wink:
     
  7. Dakta

    Dakta

    Joined:
    Apr 8, 2008
    Posts:
    492
    Yeah, I was. Guess I need to learn JavaScript