Search Unity

how to fix

Discussion in 'Scripting' started by joyfelix, Sep 11, 2019.

  1. joyfelix

    joyfelix

    Joined:
    Sep 11, 2019
    Posts:
    6
    Assets/BallControl.js(9,9): BCE0144: 'UnityEngine.Component.rigidbody' is obsolete. Property rigidbody has been deprecated. Use GetComponent<Rigidbody>() instead. (UnityUpgradable)

    and

    Assets/BallControl.js(9,19): BCE0019: 'AddRelativeTorque' is not a member of 'UnityEngine.Component'.

    from this script

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var rotationSpeed = 100;
    4.  
    5. function Update ()
    6. {
    7.     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    8.     rotation *= Time.deltaTime;
    9.     rigidbody.AddRelativeTorque (Vector3.back * rotation);
    10. }
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    Surely this message is pretty clear. Isn't it? you need delete rigidbody and use GetComponent<Rigidbody>() instead. This will fix your other error too.
     
    Joe-Censored likes this.
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Also, Javascript itself has been deprecated for years. Whatever tutorial or sample code you're using that is having you use Javascript is hopelessly out of date and will only cause you trouble and annoyance.
     
    Last edited: Sep 11, 2019
    Joe-Censored likes this.
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,639
    Oh, good point! I didn't notice that.
     
    Joe-Censored likes this.
  5. sxa

    sxa

    Joined:
    Aug 8, 2014
    Posts:
    741
    Please dont start duplicate threads. You started this after already being told what this was obsolete in your other thread.
     
    Joe-Censored likes this.
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You will need to use updated tutorials on an updated version of Unity. See the learn section link at the top of this site. You can only use C#.
     
    Joe-Censored likes this.