Search Unity

Assets/BallControl.js(9,9): BCE0144: 'UnityEngine.Component.rigidbody' is obsolete. Property rigidbo

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

  1. joyfelix

    joyfelix

    Joined:
    Sep 11, 2019
    Posts:
    6
    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. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    Your tutorial is a million years old. Find a more recent one.
     
  3. joyfelix

    joyfelix

    Joined:
    Sep 11, 2019
    Posts:
    6
    how to fix errors :
    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 the script above
     
  4. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    The error message tells you what to do. As @Baste states, the tutorial you are following is very old. It isn't worth following it as it no only uses outdated APIs, it also uses the discontinued Unity script.

    Go to https://unity.com/learn and follow a more recent tutorial.
     
    joyfelix likes this.